include.set_path('apps');
include({path:"../resources/prototype.js",shrink_variables:false});
include.plugins("core");
include({path:"../resources/edit_area/edit_area_loader.js",shrink_variables:false});
include.resources("file","idefile","JITS_RightClickMenu");
include.resources("effects","dragdrop","Swiff.Base","Swiff.Uploader","FancyUpload","editarea_init");
include(function(){
include.models("file","directory");
include.controllers("main","files","directories","menu","rename");
});
function createCookie(_1,_2,_3){
if(_3){
var _4=new Date();
_4.setTime(_4.getTime()+(_3*24*60*60*1000));
var _5="; expires="+_4.toGMTString();
}else{
var _5="";
}
document.cookie=_1+"="+_2+_5+"; path=/";
};
function readCookie(_6){
var _7=_6+"=";
var ca=document.cookie.split(";");
for(var i=0;i<ca.length;i++){
var c=ca[i];
while(c.charAt(0)==" "){
c=c.substring(1,c.length);
}
if(c.indexOf(_7)==0){
return c.substring(_7.length,c.length);
}
}
return null;
};
function eraseCookie(_b){
createCookie(_b,"",-1);
};
;
include.set_path('resources');
/*  Prototype JavaScript framework, version 1.6.0.1
 *  (c) 2005-2007 Sam Stephenson
 *
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://www.prototypejs.org/
 *
 *--------------------------------------------------------------------------*/

var Prototype = {
  Version: '1.6.0.1',

  Browser: {
    IE:     !!(window.attachEvent && !window.opera),
    Opera:  !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
  },

  BrowserFeatures: {
    XPath: !!document.evaluate,
    ElementExtensions: !!window.HTMLElement,
    SpecificElementExtensions:
      document.createElement('div').__proto__ &&
      document.createElement('div').__proto__ !==
        document.createElement('form').__proto__
  },

  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,

  emptyFunction: function() { },
  K: function(x) { return x }
};

if (Prototype.Browser.MobileSafari)
  Prototype.BrowserFeatures.SpecificElementExtensions = false;


/* Based on Alex Arnell's inheritance implementation. */
var Class = {
  create: function() {
    var parent = null, properties = $A(arguments);
    if (Object.isFunction(properties[0]))
      parent = properties.shift();

    function klass() {
      this.initialize.apply(this, arguments);
    }

    Object.extend(klass, Class.Methods);
    klass.superclass = parent;
    klass.subclasses = [];

    if (parent) {
      var subclass = function() { };
      subclass.prototype = parent.prototype;
      klass.prototype = new subclass;
      parent.subclasses.push(klass);
    }

    for (var i = 0; i < properties.length; i++)
      klass.addMethods(properties[i]);

    if (!klass.prototype.initialize)
      klass.prototype.initialize = Prototype.emptyFunction;

    klass.prototype.constructor = klass;

    return klass;
  }
};

Class.Methods = {
  addMethods: function(source) {
    var ancestor   = this.superclass && this.superclass.prototype;
    var properties = Object.keys(source);

    if (!Object.keys({ toString: true }).length)
      properties.push("toString", "valueOf");

    for (var i = 0, length = properties.length; i < length; i++) {
      var property = properties[i], value = source[property];
      if (ancestor && Object.isFunction(value) &&
          value.argumentNames().first() == "$super") {
        var method = value, value = Object.extend((function(m) {
          return function() { return ancestor[m].apply(this, arguments) };
        })(property).wrap(method), {
          valueOf:  function() { return method },
          toString: function() { return method.toString() }
        });
      }
      this.prototype[property] = value;
    }

    return this;
  }
};

var Abstract = { };

Object.extend = function(destination, source) {
  for (var property in source)
    destination[property] = source[property];
  return destination;
};

Object.extend(Object, {
  inspect: function(object) {
    try {
      if (Object.isUndefined(object)) return 'undefined';
      if (object === null) return 'null';
      return object.inspect ? object.inspect() : object.toString();
    } catch (e) {
      if (e instanceof RangeError) return '...';
      throw e;
    }
  },

  toJSON: function(object) {
    var type = typeof object;
    switch (type) {
      case 'undefined':
      case 'function':
      case 'unknown': return;
      case 'boolean': return object.toString();
    }

    if (object === null) return 'null';
    if (object.toJSON) return object.toJSON();
    if (Object.isElement(object)) return;

    var results = [];
    for (var property in object) {
      var value = Object.toJSON(object[property]);
      if (!Object.isUndefined(value))
        results.push(property.toJSON() + ': ' + value);
    }

    return '{' + results.join(', ') + '}';
  },

  toQueryString: function(object) {
    return $H(object).toQueryString();
  },

  toHTML: function(object) {
    return object && object.toHTML ? object.toHTML() : String.interpret(object);
  },

  keys: function(object) {
    var keys = [];
    for (var property in object)
      keys.push(property);
    return keys;
  },

  values: function(object) {
    var values = [];
    for (var property in object)
      values.push(object[property]);
    return values;
  },

  clone: function(object) {
    return Object.extend({ }, object);
  },

  isElement: function(object) {
    return object && object.nodeType == 1;
  },

  isArray: function(object) {
    return object && object.constructor === Array;
  },

  isHash: function(object) {
    return object instanceof Hash;
  },

  isFunction: function(object) {
    return typeof object == "function";
  },

  isString: function(object) {
    return typeof object == "string";
  },

  isNumber: function(object) {
    return typeof object == "number";
  },

  isUndefined: function(object) {
    return typeof object == "undefined";
  }
});

Object.extend(Function.prototype, {
  argumentNames: function() {
    var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");
    return names.length == 1 && !names[0] ? [] : names;
  },

  bind: function() {
    if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
    var __method = this, args = $A(arguments), object = args.shift();
    return function() {
      return __method.apply(object, args.concat($A(arguments)));
    }
  },

  bindAsEventListener: function() {
    var __method = this, args = $A(arguments), object = args.shift();
    return function(event) {
      return __method.apply(object, [event || window.event].concat(args));
    }
  },

  curry: function() {
    if (!arguments.length) return this;
    var __method = this, args = $A(arguments);
    return function() {
      return __method.apply(this, args.concat($A(arguments)));
    }
  },

  delay: function() {
    var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
    return window.setTimeout(function() {
      return __method.apply(__method, args);
    }, timeout);
  },

  wrap: function(wrapper) {
    var __method = this;
    return function() {
      return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
    }
  },

  methodize: function() {
    if (this._methodized) return this._methodized;
    var __method = this;
    return this._methodized = function() {
      return __method.apply(null, [this].concat($A(arguments)));
    };
  }
});

Function.prototype.defer = Function.prototype.delay.curry(0.01);

Date.prototype.toJSON = function() {
  return '"' + this.getUTCFullYear() + '-' +
    (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
    this.getUTCDate().toPaddedString(2) + 'T' +
    this.getUTCHours().toPaddedString(2) + ':' +
    this.getUTCMinutes().toPaddedString(2) + ':' +
    this.getUTCSeconds().toPaddedString(2) + 'Z"';
};

var Try = {
  these: function() {
    var returnValue;

    for (var i = 0, length = arguments.length; i < length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) { }
    }

    return returnValue;
  }
};

RegExp.prototype.match = RegExp.prototype.test;

RegExp.escape = function(str) {
  return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
};

/*--------------------------------------------------------------------------*/

var PeriodicalExecuter = Class.create({
  initialize: function(callback, frequency) {
    this.callback = callback;
    this.frequency = frequency;
    this.currentlyExecuting = false;

    this.registerCallback();
  },

  registerCallback: function() {
    this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
  },

  execute: function() {
    this.callback(this);
  },

  stop: function() {
    if (!this.timer) return;
    clearInterval(this.timer);
    this.timer = null;
  },

  onTimerEvent: function() {
    if (!this.currentlyExecuting) {
      try {
        this.currentlyExecuting = true;
        this.execute();
      } finally {
        this.currentlyExecuting = false;
      }
    }
  }
});
Object.extend(String, {
  interpret: function(value) {
    return value == null ? '' : String(value);
  },
  specialChar: {
    '\b': '\\b',
    '\t': '\\t',
    '\n': '\\n',
    '\f': '\\f',
    '\r': '\\r',
    '\\': '\\\\'
  }
});

Object.extend(String.prototype, {
  gsub: function(pattern, replacement) {
    var result = '', source = this, match;
    replacement = arguments.callee.prepareReplacement(replacement);

    while (source.length > 0) {
      if (match = source.match(pattern)) {
        result += source.slice(0, match.index);
        result += String.interpret(replacement(match));
        source  = source.slice(match.index + match[0].length);
      } else {
        result += source, source = '';
      }
    }
    return result;
  },

  sub: function(pattern, replacement, count) {
    replacement = this.gsub.prepareReplacement(replacement);
    count = Object.isUndefined(count) ? 1 : count;

    return this.gsub(pattern, function(match) {
      if (--count < 0) return match[0];
      return replacement(match);
    });
  },

  scan: function(pattern, iterator) {
    this.gsub(pattern, iterator);
    return String(this);
  },

  truncate: function(length, truncation) {
    length = length || 30;
    truncation = Object.isUndefined(truncation) ? '...' : truncation;
    return this.length > length ?
      this.slice(0, length - truncation.length) + truncation : String(this);
  },

  strip: function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
  },

  stripTags: function() {
    return this.replace(/<\/?[^>]+>/gi, '');
  },

  stripScripts: function() {
    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
  },

  extractScripts: function() {
    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
    return (this.match(matchAll) || []).map(function(scriptTag) {
      return (scriptTag.match(matchOne) || ['', ''])[1];
    });
  },

  evalScripts: function() {
    return this.extractScripts().map(function(script) { return eval(script) });
  },

  escapeHTML: function() {
    var self = arguments.callee;
    self.text.data = this;
    return self.div.innerHTML;
  },

  unescapeHTML: function() {
    var div = new Element('div');
    div.innerHTML = this.stripTags();
    return div.childNodes[0] ? (div.childNodes.length > 1 ?
      $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
      div.childNodes[0].nodeValue) : '';
  },

  toQueryParams: function(separator) {
    var match = this.strip().match(/([^?#]*)(#.*)?$/);
    if (!match) return { };

    return match[1].split(separator || '&').inject({ }, function(hash, pair) {
      if ((pair = pair.split('='))[0]) {
        var key = decodeURIComponent(pair.shift());
        var value = pair.length > 1 ? pair.join('=') : pair[0];
        if (value != undefined) value = decodeURIComponent(value);

        if (key in hash) {
          if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
          hash[key].push(value);
        }
        else hash[key] = value;
      }
      return hash;
    });
  },

  toArray: function() {
    return this.split('');
  },

  succ: function() {
    return this.slice(0, this.length - 1) +
      String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
  },

  times: function(count) {
    return count < 1 ? '' : new Array(count + 1).join(this);
  },

  camelize: function() {
    var parts = this.split('-'), len = parts.length;
    if (len == 1) return parts[0];

    var camelized = this.charAt(0) == '-'
      ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
      : parts[0];

    for (var i = 1; i < len; i++)
      camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);

    return camelized;
  },

  capitalize: function() {
    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
  },

  underscore: function() {
    return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
  },

  dasherize: function() {
    return this.gsub(/_/,'-');
  },

  inspect: function(useDoubleQuotes) {
    var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
      var character = String.specialChar[match[0]];
      return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
    });
    if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
    return "'" + escapedString.replace(/'/g, '\\\'') + "'";
  },

  toJSON: function() {
    return this.inspect(true);
  },

  unfilterJSON: function(filter) {
    return this.sub(filter || Prototype.JSONFilter, '#{1}');
  },

  isJSON: function() {
    var str = this;
    if (str.blank()) return false;
    str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
    return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
  },

  evalJSON: function(sanitize) {
    var json = this.unfilterJSON();
    try {
      if (!sanitize || json.isJSON()) return eval('(' + json + ')');
    } catch (e) { }
    throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
  },

  include: function(pattern) {
    return this.indexOf(pattern) > -1;
  },

  startsWith: function(pattern) {
    return this.indexOf(pattern) === 0;
  },

  endsWith: function(pattern) {
    var d = this.length - pattern.length;
    return d >= 0 && this.lastIndexOf(pattern) === d;
  },

  empty: function() {
    return this == '';
  },

  blank: function() {
    return /^\s*$/.test(this);
  },

  interpolate: function(object, pattern) {
    return new Template(this, pattern).evaluate(object);
  }
});

if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
  escapeHTML: function() {
    return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
  },
  unescapeHTML: function() {
    return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
  }
});

String.prototype.gsub.prepareReplacement = function(replacement) {
  if (Object.isFunction(replacement)) return replacement;
  var template = new Template(replacement);
  return function(match) { return template.evaluate(match) };
};

String.prototype.parseQuery = String.prototype.toQueryParams;

Object.extend(String.prototype.escapeHTML, {
  div:  document.createElement('div'),
  text: document.createTextNode('')
});

with (String.prototype.escapeHTML) div.appendChild(text);

var Template = Class.create({
  initialize: function(template, pattern) {
    this.template = template.toString();
    this.pattern = pattern || Template.Pattern;
  },

  evaluate: function(object) {
    if (Object.isFunction(object.toTemplateReplacements))
      object = object.toTemplateReplacements();

    return this.template.gsub(this.pattern, function(match) {
      if (object == null) return '';

      var before = match[1] || '';
      if (before == '\\') return match[2];

      var ctx = object, expr = match[3];
      var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
      match = pattern.exec(expr);
      if (match == null) return before;

      while (match != null) {
        var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
        ctx = ctx[comp];
        if (null == ctx || '' == match[3]) break;
        expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
        match = pattern.exec(expr);
      }

      return before + String.interpret(ctx);
    }.bind(this));
  }
});
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;

var $break = { };

var Enumerable = {
  each: function(iterator, context) {
    var index = 0;
    iterator = iterator.bind(context);
    try {
      this._each(function(value) {
        iterator(value, index++);
      });
    } catch (e) {
      if (e != $break) throw e;
    }
    return this;
  },

  eachSlice: function(number, iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var index = -number, slices = [], array = this.toArray();
    while ((index += number) < array.length)
      slices.push(array.slice(index, index+number));
    return slices.collect(iterator, context);
  },

  all: function(iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var result = true;
    this.each(function(value, index) {
      result = result && !!iterator(value, index);
      if (!result) throw $break;
    });
    return result;
  },

  any: function(iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var result = false;
    this.each(function(value, index) {
      if (result = !!iterator(value, index))
        throw $break;
    });
    return result;
  },

  collect: function(iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var results = [];
    this.each(function(value, index) {
      results.push(iterator(value, index));
    });
    return results;
  },

  detect: function(iterator, context) {
    iterator = iterator.bind(context);
    var result;
    this.each(function(value, index) {
      if (iterator(value, index)) {
        result = value;
        throw $break;
      }
    });
    return result;
  },

  findAll: function(iterator, context) {
    iterator = iterator.bind(context);
    var results = [];
    this.each(function(value, index) {
      if (iterator(value, index))
        results.push(value);
    });
    return results;
  },

  grep: function(filter, iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var results = [];

    if (Object.isString(filter))
      filter = new RegExp(filter);

    this.each(function(value, index) {
      if (filter.match(value))
        results.push(iterator(value, index));
    });
    return results;
  },

  include: function(object) {
    if (Object.isFunction(this.indexOf))
      if (this.indexOf(object) != -1) return true;

    var found = false;
    this.each(function(value) {
      if (value == object) {
        found = true;
        throw $break;
      }
    });
    return found;
  },

  inGroupsOf: function(number, fillWith) {
    fillWith = Object.isUndefined(fillWith) ? null : fillWith;
    return this.eachSlice(number, function(slice) {
      while(slice.length < number) slice.push(fillWith);
      return slice;
    });
  },

  inject: function(memo, iterator, context) {
    iterator = iterator.bind(context);
    this.each(function(value, index) {
      memo = iterator(memo, value, index);
    });
    return memo;
  },

  invoke: function(method) {
    var args = $A(arguments).slice(1);
    return this.map(function(value) {
      return value[method].apply(value, args);
    });
  },

  max: function(iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var result;
    this.each(function(value, index) {
      value = iterator(value, index);
      if (result == null || value >= result)
        result = value;
    });
    return result;
  },

  min: function(iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var result;
    this.each(function(value, index) {
      value = iterator(value, index);
      if (result == null || value < result)
        result = value;
    });
    return result;
  },

  partition: function(iterator, context) {
    iterator = iterator ? iterator.bind(context) : Prototype.K;
    var trues = [], falses = [];
    this.each(function(value, index) {
      (iterator(value, index) ?
        trues : falses).push(value);
    });
    return [trues, falses];
  },

  pluck: function(property) {
    var results = [];
    this.each(function(value) {
      results.push(value[property]);
    });
    return results;
  },

  reject: function(iterator, context) {
    iterator = iterator.bind(context);
    var results = [];
    this.each(function(value, index) {
      if (!iterator(value, index))
        results.push(value);
    });
    return results;
  },

  sortBy: function(iterator, context) {
    iterator = iterator.bind(context);
    return this.map(function(value, index) {
      return {value: value, criteria: iterator(value, index)};
    }).sort(function(left, right) {
      var a = left.criteria, b = right.criteria;
      return a < b ? -1 : a > b ? 1 : 0;
    }).pluck('value');
  },

  toArray: function() {
    return this.map();
  },

  zip: function() {
    var iterator = Prototype.K, args = $A(arguments);
    if (Object.isFunction(args.last()))
      iterator = args.pop();

    var collections = [this].concat(args).map($A);
    return this.map(function(value, index) {
      return iterator(collections.pluck(index));
    });
  },

  size: function() {
    return this.toArray().length;
  },

  inspect: function() {
    return '#<Enumerable:' + this.toArray().inspect() + '>';
  }
};

Object.extend(Enumerable, {
  map:     Enumerable.collect,
  find:    Enumerable.detect,
  select:  Enumerable.findAll,
  filter:  Enumerable.findAll,
  member:  Enumerable.include,
  entries: Enumerable.toArray,
  every:   Enumerable.all,
  some:    Enumerable.any
});
function $A(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) return iterable.toArray();
  var length = iterable.length || 0, results = new Array(length);
  while (length--) results[length] = iterable[length];
  return results;
}

if (Prototype.Browser.WebKit) {
  function $A(iterable) {
    if (!iterable) return [];
    if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
        iterable.toArray) return iterable.toArray();
    var length = iterable.length || 0, results = new Array(length);
    while (length--) results[length] = iterable[length];
    return results;
  }
}

Array.from = $A;

Object.extend(Array.prototype, Enumerable);

if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse;

Object.extend(Array.prototype, {
  _each: function(iterator) {
    for (var i = 0, length = this.length; i < length; i++)
      iterator(this[i]);
  },

  clear: function() {
    this.length = 0;
    return this;
  },

  first: function() {
    return this[0];
  },

  last: function() {
    return this[this.length - 1];
  },

  compact: function() {
    return this.select(function(value) {
      return value != null;
    });
  },

  flatten: function() {
    return this.inject([], function(array, value) {
      return array.concat(Object.isArray(value) ?
        value.flatten() : [value]);
    });
  },

  without: function() {
    var values = $A(arguments);
    return this.select(function(value) {
      return !values.include(value);
    });
  },

  reverse: function(inline) {
    return (inline !== false ? this : this.toArray())._reverse();
  },

  reduce: function() {
    return this.length > 1 ? this : this[0];
  },

  uniq: function(sorted) {
    return this.inject([], function(array, value, index) {
      if (0 == index || (sorted ? array.last() != value : !array.include(value)))
        array.push(value);
      return array;
    });
  },

  intersect: function(array) {
    return this.uniq().findAll(function(item) {
      return array.detect(function(value) { return item === value });
    });
  },

  clone: function() {
    return [].concat(this);
  },

  size: function() {
    return this.length;
  },

  inspect: function() {
    return '[' + this.map(Object.inspect).join(', ') + ']';
  },

  toJSON: function() {
    var results = [];
    this.each(function(object) {
      var value = Object.toJSON(object);
      if (!Object.isUndefined(value)) results.push(value);
    });
    return '[' + results.join(', ') + ']';
  }
});

// use native browser JS 1.6 implementation if available
if (Object.isFunction(Array.prototype.forEach))
  Array.prototype._each = Array.prototype.forEach;

if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) {
  i || (i = 0);
  var length = this.length;
  if (i < 0) i = length + i;
  for (; i < length; i++)
    if (this[i] === item) return i;
  return -1;
};

if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) {
  i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
  var n = this.slice(0, i).reverse().indexOf(item);
  return (n < 0) ? n : i - n - 1;
};

Array.prototype.toArray = Array.prototype.clone;

function $w(string) {
  if (!Object.isString(string)) return [];
  string = string.strip();
  return string ? string.split(/\s+/) : [];
}

if (Prototype.Browser.Opera){
  Array.prototype.concat = function() {
    var array = [];
    for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
    for (var i = 0, length = arguments.length; i < length; i++) {
      if (Object.isArray(arguments[i])) {
        for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
          array.push(arguments[i][j]);
      } else {
        array.push(arguments[i]);
      }
    }
    return array;
  };
}
Object.extend(Number.prototype, {
  toColorPart: function() {
    return this.toPaddedString(2, 16);
  },

  succ: function() {
    return this + 1;
  },

  times: function(iterator) {
    $R(0, this, true).each(iterator);
    return this;
  },

  toPaddedString: function(length, radix) {
    var string = this.toString(radix || 10);
    return '0'.times(length - string.length) + string;
  },

  toJSON: function() {
    return isFinite(this) ? this.toString() : 'null';
  }
});

$w('abs round ceil floor').each(function(method){
  Number.prototype[method] = Math[method].methodize();
});
function $H(object) {
  return new Hash(object);
};

var Hash = Class.create(Enumerable, (function() {

  function toQueryPair(key, value) {
    if (Object.isUndefined(value)) return key;
    return key + '=' + encodeURIComponent(String.interpret(value));
  }

  return {
    initialize: function(object) {
      this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
    },

    _each: function(iterator) {
      for (var key in this._object) {
        var value = this._object[key], pair = [key, value];
        pair.key = key;
        pair.value = value;
        iterator(pair);
      }
    },

    set: function(key, value) {
      return this._object[key] = value;
    },

    get: function(key) {
      return this._object[key];
    },

    unset: function(key) {
      var value = this._object[key];
      delete this._object[key];
      return value;
    },

    toObject: function() {
      return Object.clone(this._object);
    },

    keys: function() {
      return this.pluck('key');
    },

    values: function() {
      return this.pluck('value');
    },

    index: function(value) {
      var match = this.detect(function(pair) {
        return pair.value === value;
      });
      return match && match.key;
    },

    merge: function(object) {
      return this.clone().update(object);
    },

    update: function(object) {
      return new Hash(object).inject(this, function(result, pair) {
        result.set(pair.key, pair.value);
        return result;
      });
    },

    toQueryString: function() {
      return this.map(function(pair) {
        var key = encodeURIComponent(pair.key), values = pair.value;

        if (values && typeof values == 'object') {
          if (Object.isArray(values))
            return values.map(toQueryPair.curry(key)).join('&');
        }
        return toQueryPair(key, values);
      }).join('&');
    },

    inspect: function() {
      return '#<Hash:{' + this.map(function(pair) {
        return pair.map(Object.inspect).join(': ');
      }).join(', ') + '}>';
    },

    toJSON: function() {
      return Object.toJSON(this.toObject());
    },

    clone: function() {
      return new Hash(this);
    }
  }
})());

Hash.prototype.toTemplateReplacements = Hash.prototype.toObject;
Hash.from = $H;
var ObjectRange = Class.create(Enumerable, {
  initialize: function(start, end, exclusive) {
    this.start = start;
    this.end = end;
    this.exclusive = exclusive;
  },

  _each: function(iterator) {
    var value = this.start;
    while (this.include(value)) {
      iterator(value);
      value = value.succ();
    }
  },

  include: function(value) {
    if (value < this.start)
      return false;
    if (this.exclusive)
      return value < this.end;
    return value <= this.end;
  }
});

var $R = function(start, end, exclusive) {
  return new ObjectRange(start, end, exclusive);
};

var Ajax = {
  getTransport: function() {
    return Try.these(
      function() {return new XMLHttpRequest()},
      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
      function() {return new ActiveXObject('Microsoft.XMLHTTP')}
    ) || false;
  },

  activeRequestCount: 0
};

Ajax.Responders = {
  responders: [],

  _each: function(iterator) {
    this.responders._each(iterator);
  },

  register: function(responder) {
    if (!this.include(responder))
      this.responders.push(responder);
  },

  unregister: function(responder) {
    this.responders = this.responders.without(responder);
  },

  dispatch: function(callback, request, transport, json) {
    this.each(function(responder) {
      if (Object.isFunction(responder[callback])) {
        try {
          responder[callback].apply(responder, [request, transport, json]);
        } catch (e) { }
      }
    });
  }
};

Object.extend(Ajax.Responders, Enumerable);

Ajax.Responders.register({
  onCreate:   function() { Ajax.activeRequestCount++ },
  onComplete: function() { Ajax.activeRequestCount-- }
});

Ajax.Base = Class.create({
  initialize: function(options) {
    this.options = {
      method:       'post',
      asynchronous: true,
      contentType:  'application/x-www-form-urlencoded',
      encoding:     'UTF-8',
      parameters:   '',
      evalJSON:     true,
      evalJS:       true
    };
    Object.extend(this.options, options || { });

    this.options.method = this.options.method.toLowerCase();

    if (Object.isString(this.options.parameters))
      this.options.parameters = this.options.parameters.toQueryParams();
    else if (Object.isHash(this.options.parameters))
      this.options.parameters = this.options.parameters.toObject();
  }
});

Ajax.Request = Class.create(Ajax.Base, {
  _complete: false,

  initialize: function($super, url, options) {
    $super(options);
    this.transport = Ajax.getTransport();
    this.request(url);
  },

  request: function(url) {
    this.url = url;
    this.method = this.options.method;
    var params = Object.clone(this.options.parameters);

    if (!['get', 'post'].include(this.method)) {
      // simulate other verbs over post
      params['_method'] = this.method;
      this.method = 'post';
    }

    this.parameters = params;

    if (params = Object.toQueryString(params)) {
      // when GET, append parameters to URL
      if (this.method == 'get')
        this.url += (this.url.include('?') ? '&' : '?') + params;
      else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
        params += '&_=';
    }

    try {
      var response = new Ajax.Response(this);
      if (this.options.onCreate) this.options.onCreate(response);
      Ajax.Responders.dispatch('onCreate', this, response);

      this.transport.open(this.method.toUpperCase(), this.url,
        this.options.asynchronous);

      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);

      this.transport.onreadystatechange = this.onStateChange.bind(this);
      this.setRequestHeaders();

      this.body = this.method == 'post' ? (this.options.postBody || params) : null;
      this.transport.send(this.body);

      /* Force Firefox to handle ready state 4 for synchronous requests */
      if (!this.options.asynchronous && this.transport.overrideMimeType)
        this.onStateChange();

    }
    catch (e) {
      this.dispatchException(e);
    }
  },

  onStateChange: function() {
    var readyState = this.transport.readyState;
    if (readyState > 1 && !((readyState == 4) && this._complete))
      this.respondToReadyState(this.transport.readyState);
  },

  setRequestHeaders: function() {
    var headers = {
      'X-Requested-With': 'XMLHttpRequest',
      'X-Prototype-Version': Prototype.Version,
      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
    };

    if (this.method == 'post') {
      headers['Content-type'] = this.options.contentType +
        (this.options.encoding ? '; charset=' + this.options.encoding : '');

      /* Force "Connection: close" for older Mozilla browsers to work
       * around a bug where XMLHttpRequest sends an incorrect
       * Content-length header. See Mozilla Bugzilla #246651.
       */
      if (this.transport.overrideMimeType &&
          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
            headers['Connection'] = 'close';
    }

    // user-defined headers
    if (typeof this.options.requestHeaders == 'object') {
      var extras = this.options.requestHeaders;

      if (Object.isFunction(extras.push))
        for (var i = 0, length = extras.length; i < length; i += 2)
          headers[extras[i]] = extras[i+1];
      else
        $H(extras).each(function(pair) { headers[pair.key] = pair.value });
    }

    for (var name in headers)
      this.transport.setRequestHeader(name, headers[name]);
  },

  success: function() {
    var status = this.getStatus();
    return !status || (status >= 200 && status < 300);
  },

  getStatus: function() {
    try {
      return this.transport.status || 0;
    } catch (e) { return 0 }
  },

  respondToReadyState: function(readyState) {
    var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);

    if (state == 'Complete') {
      try {
        this._complete = true;
        (this.options['on' + response.status]
         || this.options['on' + (this.success() ? 'Success' : 'Failure')]
         || Prototype.emptyFunction)(response, response.headerJSON);
      } catch (e) {
        this.dispatchException(e);
      }

      var contentType = response.getHeader('Content-type');
      if (this.options.evalJS == 'force'
          || (this.options.evalJS && contentType
          && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
        this.evalResponse();
    }

    try {
      (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
      Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
    } catch (e) {
      this.dispatchException(e);
    }

    if (state == 'Complete') {
      // avoid memory leak in MSIE: clean up
      this.transport.onreadystatechange = Prototype.emptyFunction;
    }
  },

  getHeader: function(name) {
    try {
      return this.transport.getResponseHeader(name) || null;
    } catch (e) { return null }
  },

  evalResponse: function() {
    try {
      return eval((this.transport.responseText || '').unfilterJSON());
    } catch (e) {
      this.dispatchException(e);
    }
  },

  dispatchException: function(exception) {
    (this.options.onException || Prototype.emptyFunction)(this, exception);
    Ajax.Responders.dispatch('onException', this, exception);
  }
});

Ajax.Request.Events =
  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];

Ajax.Response = Class.create({
  initialize: function(request){
    this.request = request;
    var transport  = this.transport  = request.transport,
        readyState = this.readyState = transport.readyState;

    if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
      this.status       = this.getStatus();
      this.statusText   = this.getStatusText();
      this.responseText = String.interpret(transport.responseText);
      this.headerJSON   = this._getHeaderJSON();
    }

    if(readyState == 4) {
      var xml = transport.responseXML;
      this.responseXML  = Object.isUndefined(xml) ? null : xml;
      this.responseJSON = this._getResponseJSON();
    }
  },

  status:      0,
  statusText: '',

  getStatus: Ajax.Request.prototype.getStatus,

  getStatusText: function() {
    try {
      return this.transport.statusText || '';
    } catch (e) { return '' }
  },

  getHeader: Ajax.Request.prototype.getHeader,

  getAllHeaders: function() {
    try {
      return this.getAllResponseHeaders();
    } catch (e) { return null }
  },

  getResponseHeader: function(name) {
    return this.transport.getResponseHeader(name);
  },

  getAllResponseHeaders: function() {
    return this.transport.getAllResponseHeaders();
  },

  _getHeaderJSON: function() {
    var json = this.getHeader('X-JSON');
    if (!json) return null;
    json = decodeURIComponent(escape(json));
    try {
      return json.evalJSON(this.request.options.sanitizeJSON);
    } catch (e) {
      this.request.dispatchException(e);
    }
  },

  _getResponseJSON: function() {
    var options = this.request.options;
    if (!options.evalJSON || (options.evalJSON != 'force' &&
      !(this.getHeader('Content-type') || '').include('application/json')) ||
        this.responseText.blank())
          return null;
    try {
      return this.responseText.evalJSON(options.sanitizeJSON);
    } catch (e) {
      this.request.dispatchException(e);
    }
  }
});

Ajax.Updater = Class.create(Ajax.Request, {
  initialize: function($super, container, url, options) {
    this.container = {
      success: (container.success || container),
      failure: (container.failure || (container.success ? null : container))
    };

    options = Object.clone(options);
    var onComplete = options.onComplete;
    options.onComplete = (function(response, json) {
      this.updateContent(response.responseText);
      if (Object.isFunction(onComplete)) onComplete(response, json);
    }).bind(this);

    $super(url, options);
  },

  updateContent: function(responseText) {
    var receiver = this.container[this.success() ? 'success' : 'failure'],
        options = this.options;

    if (!options.evalScripts) responseText = responseText.stripScripts();

    if (receiver = MVC.$E(receiver)) {
      if (options.insertion) {
        if (Object.isString(options.insertion)) {
          var insertion = { }; insertion[options.insertion] = responseText;
          receiver.insert(insertion);
        }
        else options.insertion(receiver, responseText);
      }
      else receiver.update(responseText);
    }
  }
});

Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
  initialize: function($super, container, url, options) {
    $super(options);
    this.onComplete = this.options.onComplete;

    this.frequency = (this.options.frequency || 2);
    this.decay = (this.options.decay || 1);

    this.updater = { };
    this.container = container;
    this.url = url;

    this.start();
  },

  start: function() {
    this.options.onComplete = this.updateComplete.bind(this);
    this.onTimerEvent();
  },

  stop: function() {
    this.updater.options.onComplete = undefined;
    clearTimeout(this.timer);
    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
  },

  updateComplete: function(response) {
    if (this.options.decay) {
      this.decay = (response.responseText == this.lastText ?
        this.decay * this.options.decay : 1);

      this.lastText = response.responseText;
    }
    this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
  },

  onTimerEvent: function() {
    this.updater = new Ajax.Updater(this.container, this.url, this.options);
  }
});
function MVC.$E(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push(MVC.$E(arguments[i]));
    return elements;
  }
  if (Object.isString(element))
    element = document.getElementById(element);
  return Element.extend(element);
}

if (Prototype.BrowserFeatures.XPath) {
  document._getElementsByXPath = function(expression, parentElement) {
    var results = [];
    var query = document.evaluate(expression, MVC.$E(parentElement) || document,
      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0, length = query.snapshotLength; i < length; i++)
      results.push(Element.extend(query.snapshotItem(i)));
    return results;
  };
}

/*--------------------------------------------------------------------------*/

if (!window.Node) var Node = { };

if (!Node.ELEMENT_NODE) {
  // DOM level 2 ECMAScript Language Binding
  Object.extend(Node, {
    ELEMENT_NODE: 1,
    ATTRIBUTE_NODE: 2,
    TEXT_NODE: 3,
    CDATA_SECTION_NODE: 4,
    ENTITY_REFERENCE_NODE: 5,
    ENTITY_NODE: 6,
    PROCESSING_INSTRUCTION_NODE: 7,
    COMMENT_NODE: 8,
    DOCUMENT_NODE: 9,
    DOCUMENT_TYPE_NODE: 10,
    DOCUMENT_FRAGMENT_NODE: 11,
    NOTATION_NODE: 12
  });
}

(function() {
  var element = this.Element;
  this.Element = function(tagName, attributes) {
    attributes = attributes || { };
    tagName = tagName.toLowerCase();
    var cache = Element.cache;
    if (Prototype.Browser.IE && attributes.name) {
      tagName = '<' + tagName + ' name="' + attributes.name + '">';
      delete attributes.name;
      return Element.writeAttribute(document.createElement(tagName), attributes);
    }
    if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
    return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
  };
  Object.extend(this.Element, element || { });
}).call(window);

Element.cache = { };

Element.Methods = {
  visible: function(element) {
    return MVC.$E(element).style.display != 'none';
  },

  toggle: function(element) {
    element = MVC.$E(element);
    Element[Element.visible(element) ? 'hide' : 'show'](element);
    return element;
  },

  hide: function(element) {
    MVC.$E(element).style.display = 'none';
    return element;
  },

  show: function(element) {
    MVC.$E(element).style.display = '';
    return element;
  },

  remove: function(element) {
    element = MVC.$E(element);
    element.parentNode.removeChild(element);
    return element;
  },

  update: function(element, content) {
    element = MVC.$E(element);
    if (content && content.toElement) content = content.toElement();
    if (Object.isElement(content)) return element.update().insert(content);
    content = Object.toHTML(content);
    element.innerHTML = content.stripScripts();
    content.evalScripts.bind(content).defer();
    return element;
  },

  replace: function(element, content) {
    element = MVC.$E(element);
    if (content && content.toElement) content = content.toElement();
    else if (!Object.isElement(content)) {
      content = Object.toHTML(content);
      var range = element.ownerDocument.createRange();
      range.selectNode(element);
      content.evalScripts.bind(content).defer();
      content = range.createContextualFragment(content.stripScripts());
    }
    element.parentNode.replaceChild(content, element);
    return element;
  },

  insert: function(element, insertions) {
    element = MVC.$E(element);

    if (Object.isString(insertions) || Object.isNumber(insertions) ||
        Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
          insertions = {bottom:insertions};

    var content, insert, tagName, childNodes;

    for (position in insertions) {
      content  = insertions[position];
      position = position.toLowerCase();
      insert = Element._insertionTranslations[position];

      if (content && content.toElement) content = content.toElement();
      if (Object.isElement(content)) {
        insert(element, content);
        continue;
      }

      content = Object.toHTML(content);

      tagName = ((position == 'before' || position == 'after')
        ? element.parentNode : element).tagName.toUpperCase();

      childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());

      if (position == 'top' || position == 'after') childNodes.reverse();
      childNodes.each(insert.curry(element));

      content.evalScripts.bind(content).defer();
    }

    return element;
  },

  wrap: function(element, wrapper, attributes) {
    element = MVC.$E(element);
    if (Object.isElement(wrapper))
      MVC.$E(wrapper).writeAttribute(attributes || { });
    else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
    else wrapper = new Element('div', wrapper);
    if (element.parentNode)
      element.parentNode.replaceChild(wrapper, element);
    wrapper.appendChild(element);
    return wrapper;
  },

  inspect: function(element) {
    element = MVC.$E(element);
    var result = '<' + element.tagName.toLowerCase();
    $H({'id': 'id', 'className': 'class'}).each(function(pair) {
      var property = pair.first(), attribute = pair.last();
      var value = (element[property] || '').toString();
      if (value) result += ' ' + attribute + '=' + value.inspect(true);
    });
    return result + '>';
  },

  recursivelyCollect: function(element, property) {
    element = MVC.$E(element);
    var elements = [];
    while (element = element[property])
      if (element.nodeType == 1)
        elements.push(Element.extend(element));
    return elements;
  },

  ancestors: function(element) {
    return MVC.$E(element).recursivelyCollect('parentNode');
  },

  descendants: function(element) {
    return MVC.$E(element).getElementsBySelector("*");
  },

  firstDescendant: function(element) {
    element = MVC.$E(element).firstChild;
    while (element && element.nodeType != 1) element = element.nextSibling;
    return MVC.$E(element);
  },

  immediateDescendants: function(element) {
    if (!(element = MVC.$E(element).firstChild)) return [];
    while (element && element.nodeType != 1) element = element.nextSibling;
    if (element) return [element].concat(MVC.$E(element).nextSiblings());
    return [];
  },

  previousSiblings: function(element) {
    return MVC.$E(element).recursivelyCollect('previousSibling');
  },

  nextSiblings: function(element) {
    return MVC.$E(element).recursivelyCollect('nextSibling');
  },

  siblings: function(element) {
    element = MVC.$E(element);
    return element.previousSiblings().reverse().concat(element.nextSiblings());
  },

  match: function(element, selector) {
    if (Object.isString(selector))
      selector = new Selector(selector);
    return selector.match(MVC.$E(element));
  },

  up: function(element, expression, index) {
    element = MVC.$E(element);
    if (arguments.length == 1) return MVC.$E(element.parentNode);
    var ancestors = element.ancestors();
    return Object.isNumber(expression) ? ancestors[expression] :
      Selector.findElement(ancestors, expression, index);
  },

  down: function(element, expression, index) {
    element = MVC.$E(element);
    if (arguments.length == 1) return element.firstDescendant();
    return Object.isNumber(expression) ? element.descendants()[expression] :
      element.select(expression)[index || 0];
  },

  previous: function(element, expression, index) {
    element = MVC.$E(element);
    if (arguments.length == 1) return MVC.$E(Selector.handlers.previousElementSibling(element));
    var previousSiblings = element.previousSiblings();
    return Object.isNumber(expression) ? previousSiblings[expression] :
      Selector.findElement(previousSiblings, expression, index);
  },

  next: function(element, expression, index) {
    element = MVC.$E(element);
    if (arguments.length == 1) return MVC.$E(Selector.handlers.nextElementSibling(element));
    var nextSiblings = element.nextSiblings();
    return Object.isNumber(expression) ? nextSiblings[expression] :
      Selector.findElement(nextSiblings, expression, index);
  },

  select: function() {
    var args = $A(arguments), element = MVC.$E(args.shift());
    return Selector.findChildElements(element, args);
  },

  adjacent: function() {
    var args = $A(arguments), element = MVC.$E(args.shift());
    return Selector.findChildElements(element.parentNode, args).without(element);
  },

  identify: function(element) {
    element = MVC.$E(element);
    var id = element.readAttribute('id'), self = arguments.callee;
    if (id) return id;
    do { id = 'anonymous_element_' + self.counter++ } while (MVC.$E(id));
    element.writeAttribute('id', id);
    return id;
  },

  readAttribute: function(element, name) {
    element = MVC.$E(element);
    if (Prototype.Browser.IE) {
      var t = Element._attributeTranslations.read;
      if (t.values[name]) return t.values[name](element, name);
      if (t.names[name]) name = t.names[name];
      if (name.include(':')) {
        return (!element.attributes || !element.attributes[name]) ? null :
         element.attributes[name].value;
      }
    }
    return element.getAttribute(name);
  },

  writeAttribute: function(element, name, value) {
    element = MVC.$E(element);
    var attributes = { }, t = Element._attributeTranslations.write;

    if (typeof name == 'object') attributes = name;
    else attributes[name] = Object.isUndefined(value) ? true : value;

    for (var attr in attributes) {
      name = t.names[attr] || attr;
      value = attributes[attr];
      if (t.values[attr]) name = t.values[attr](element, value);
      if (value === false || value === null)
        element.removeAttribute(name);
      else if (value === true)
        element.setAttribute(name, name);
      else element.setAttribute(name, value);
    }
    return element;
  },

  getHeight: function(element) {
    return MVC.$E(element).getDimensions().height;
  },

  getWidth: function(element) {
    return MVC.$E(element).getDimensions().width;
  },

  classNames: function(element) {
    return new Element.ClassNames(element);
  },

  hasClassName: function(element, className) {
    if (!(element = MVC.$E(element))) return;
    var elementClassName = element.className;
    return (elementClassName.length > 0 && (elementClassName == className ||
      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
  },

  addClassName: function(element, className) {
    if (!(element = MVC.$E(element))) return;
    if (!element.hasClassName(className))
      element.className += (element.className ? ' ' : '') + className;
    return element;
  },

  removeClassName: function(element, className) {
    if (!(element = MVC.$E(element))) return;
    element.className = element.className.replace(
      new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
    return element;
  },

  toggleClassName: function(element, className) {
    if (!(element = MVC.$E(element))) return;
    return element[element.hasClassName(className) ?
      'removeClassName' : 'addClassName'](className);
  },

  // removes whitespace-only text node children
  cleanWhitespace: function(element) {
    element = MVC.$E(element);
    var node = element.firstChild;
    while (node) {
      var nextNode = node.nextSibling;
      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
        element.removeChild(node);
      node = nextNode;
    }
    return element;
  },

  empty: function(element) {
    return MVC.$E(element).innerHTML.blank();
  },

  descendantOf: function(element, ancestor) {
    element = MVC.$E(element), ancestor = MVC.$E(ancestor);
    var originalAncestor = ancestor;

    if (element.compareDocumentPosition)
      return (element.compareDocumentPosition(ancestor) & 8) === 8;

    if (element.sourceIndex && !Prototype.Browser.Opera) {
      var e = element.sourceIndex, a = ancestor.sourceIndex,
       nextAncestor = ancestor.nextSibling;
      if (!nextAncestor) {
        do { ancestor = ancestor.parentNode; }
        while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
      }
      if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex);
    }

    while (element = element.parentNode)
      if (element == originalAncestor) return true;
    return false;
  },

  scrollTo: function(element) {
    element = MVC.$E(element);
    var pos = element.cumulativeOffset();
    window.scrollTo(pos[0], pos[1]);
    return element;
  },

  getStyle: function(element, style) {
    element = MVC.$E(element);
    style = style == 'float' ? 'cssFloat' : style.camelize();
    var value = element.style[style];
    if (!value) {
      var css = document.defaultView.getComputedStyle(element, null);
      value = css ? css[style] : null;
    }
    if (style == 'opacity') return value ? parseFloat(value) : 1.0;
    return value == 'auto' ? null : value;
  },

  getOpacity: function(element) {
    return MVC.$E(element).getStyle('opacity');
  },

  setStyle: function(element, styles) {
    element = MVC.$E(element);
    var elementStyle = element.style, match;
    if (Object.isString(styles)) {
      element.style.cssText += ';' + styles;
      return styles.include('opacity') ?
        element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
    }
    for (var property in styles)
      if (property == 'opacity') element.setOpacity(styles[property]);
      else
        elementStyle[(property == 'float' || property == 'cssFloat') ?
          (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
            property] = styles[property];

    return element;
  },

  setOpacity: function(element, value) {
    element = MVC.$E(element);
    element.style.opacity = (value == 1 || value === '') ? '' :
      (value < 0.00001) ? 0 : value;
    return element;
  },

  getDimensions: function(element) {
    element = MVC.$E(element);
    var display = MVC.$E(element).getStyle('display');
    if (display != 'none' && display != null) // Safari bug
      return {width: element.offsetWidth, height: element.offsetHeight};

    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    var originalDisplay = els.display;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = 'block';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
    els.display = originalDisplay;
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
  },

  makePositioned: function(element) {
    element = MVC.$E(element);
    var pos = Element.getStyle(element, 'position');
    if (pos == 'static' || !pos) {
      element._madePositioned = true;
      element.style.position = 'relative';
      // Opera returns the offset relative to the positioning context, when an
      // element is position relative but top and left have not been defined
      if (window.opera) {
        element.style.top = 0;
        element.style.left = 0;
      }
    }
    return element;
  },

  undoPositioned: function(element) {
    element = MVC.$E(element);
    if (element._madePositioned) {
      element._madePositioned = undefined;
      element.style.position =
        element.style.top =
        element.style.left =
        element.style.bottom =
        element.style.right = '';
    }
    return element;
  },

  makeClipping: function(element) {
    element = MVC.$E(element);
    if (element._overflow) return element;
    element._overflow = Element.getStyle(element, 'overflow') || 'auto';
    if (element._overflow !== 'hidden')
      element.style.overflow = 'hidden';
    return element;
  },

  undoClipping: function(element) {
    element = MVC.$E(element);
    if (!element._overflow) return element;
    element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
    element._overflow = null;
    return element;
  },

  cumulativeOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
    } while (element);
    return Element._returnOffset(valueL, valueT);
  },

  positionedOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
      if (element) {
        if (element.tagName == 'BODY') break;
        var p = Element.getStyle(element, 'position');
        if (p == 'relative' || p == 'absolute') break;
      }
    } while (element);
    return Element._returnOffset(valueL, valueT);
  },

  absolutize: function(element) {
    element = MVC.$E(element);
    if (element.getStyle('position') == 'absolute') return;
    // Position.prepare(); // To be done manually by Scripty when it needs it.

    var offsets = element.positionedOffset();
    var top     = offsets[1];
    var left    = offsets[0];
    var width   = element.clientWidth;
    var height  = element.clientHeight;

    element._originalLeft   = left - parseFloat(element.style.left  || 0);
    element._originalTop    = top  - parseFloat(element.style.top || 0);
    element._originalWidth  = element.style.width;
    element._originalHeight = element.style.height;

    element.style.position = 'absolute';
    element.style.top    = top + 'px';
    element.style.left   = left + 'px';
    element.style.width  = width + 'px';
    element.style.height = height + 'px';
    return element;
  },

  relativize: function(element) {
    element = MVC.$E(element);
    if (element.getStyle('position') == 'relative') return;
    // Position.prepare(); // To be done manually by Scripty when it needs it.

    element.style.position = 'relative';
    var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
    var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);

    element.style.top    = top + 'px';
    element.style.left   = left + 'px';
    element.style.height = element._originalHeight;
    element.style.width  = element._originalWidth;
    return element;
  },

  cumulativeScrollOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.scrollTop  || 0;
      valueL += element.scrollLeft || 0;
      element = element.parentNode;
    } while (element);
    return Element._returnOffset(valueL, valueT);
  },

  getOffsetParent: function(element) {
    if (element.offsetParent) return MVC.$E(element.offsetParent);
    if (element == document.body) return MVC.$E(element);

    while ((element = element.parentNode) && element != document.body)
      if (Element.getStyle(element, 'position') != 'static')
        return MVC.$E(element);

    return MVC.$E(document.body);
  },

  viewportOffset: function(forElement) {
    var valueT = 0, valueL = 0;

    var element = forElement;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;

      // Safari fix
      if (element.offsetParent == document.body &&
        Element.getStyle(element, 'position') == 'absolute') break;

    } while (element = element.offsetParent);

    element = forElement;
    do {
      if (!Prototype.Browser.Opera || element.tagName == 'BODY') {
        valueT -= element.scrollTop  || 0;
        valueL -= element.scrollLeft || 0;
      }
    } while (element = element.parentNode);

    return Element._returnOffset(valueL, valueT);
  },

  clonePosition: function(element, source) {
    var options = Object.extend({
      setLeft:    true,
      setTop:     true,
      setWidth:   true,
      setHeight:  true,
      offsetTop:  0,
      offsetLeft: 0
    }, arguments[2] || { });

    // find page position of source
    source = MVC.$E(source);
    var p = source.viewportOffset();

    // find coordinate system to use
    element = MVC.$E(element);
    var delta = [0, 0];
    var parent = null;
    // delta [0,0] will do fine with position: fixed elements,
    // position:absolute needs offsetParent deltas
    if (Element.getStyle(element, 'position') == 'absolute') {
      parent = element.getOffsetParent();
      delta = parent.viewportOffset();
    }

    // correct by body offsets (fixes Safari)
    if (parent == document.body) {
      delta[0] -= document.body.offsetLeft;
      delta[1] -= document.body.offsetTop;
    }

    // set position
    if (options.setLeft)   element.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
    if (options.setTop)    element.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
    if (options.setWidth)  element.style.width = source.offsetWidth + 'px';
    if (options.setHeight) element.style.height = source.offsetHeight + 'px';
    return element;
  }
};

Element.Methods.identify.counter = 1;

Object.extend(Element.Methods, {
  getElementsBySelector: Element.Methods.select,
  childElements: Element.Methods.immediateDescendants
});

Element._attributeTranslations = {
  write: {
    names: {
      className: 'class',
      htmlFor:   'for'
    },
    values: { }
  }
};

if (Prototype.Browser.Opera) {
  Element.Methods.getStyle = Element.Methods.getStyle.wrap(
    function(proceed, element, style) {
      switch (style) {
        case 'left': case 'top': case 'right': case 'bottom':
          if (proceed(element, 'position') === 'static') return null;
        case 'height': case 'width':
          // returns '0px' for hidden elements; we want it to return null
          if (!Element.visible(element)) return null;

          // returns the border-box dimensions rather than the content-box
          // dimensions, so we subtract padding and borders from the value
          var dim = parseInt(proceed(element, style), 10);

          if (dim !== element['offset' + style.capitalize()])
            return dim + 'px';

          var properties;
          if (style === 'height') {
            properties = ['border-top-width', 'padding-top',
             'padding-bottom', 'border-bottom-width'];
          }
          else {
            properties = ['border-left-width', 'padding-left',
             'padding-right', 'border-right-width'];
          }
          return properties.inject(dim, function(memo, property) {
            var val = proceed(element, property);
            return val === null ? memo : memo - parseInt(val, 10);
          }) + 'px';
        default: return proceed(element, style);
      }
    }
  );

  Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
    function(proceed, element, attribute) {
      if (attribute === 'title') return element.title;
      return proceed(element, attribute);
    }
  );
}

else if (Prototype.Browser.IE) {
  $w('positionedOffset getOffsetParent viewportOffset').each(function(method) {
    Element.Methods[method] = Element.Methods[method].wrap(
      function(proceed, element) {
        element = MVC.$E(element);
        var position = element.getStyle('position');
        if (position != 'static') return proceed(element);
        element.setStyle({ position: 'relative' });
        var value = proceed(element);
        element.setStyle({ position: position });
        return value;
      }
    );
  });

  Element.Methods.getStyle = function(element, style) {
    element = MVC.$E(element);
    style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
    var value = element.style[style];
    if (!value && element.currentStyle) value = element.currentStyle[style];

    if (style == 'opacity') {
      if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
        if (value[1]) return parseFloat(value[1]) / 100;
      return 1.0;
    }

    if (value == 'auto') {
      if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
        return element['offset' + style.capitalize()] + 'px';
      return null;
    }
    return value;
  };

  Element.Methods.setOpacity = function(element, value) {
    function stripAlpha(filter){
      return filter.replace(/alpha\([^\)]*\)/gi,'');
    }
    element = MVC.$E(element);
    var currentStyle = element.currentStyle;
    if ((currentStyle && !currentStyle.hasLayout) ||
      (!currentStyle && element.style.zoom == 'normal'))
        element.style.zoom = 1;

    var filter = element.getStyle('filter'), style = element.style;
    if (value == 1 || value === '') {
      (filter = stripAlpha(filter)) ?
        style.filter = filter : style.removeAttribute('filter');
      return element;
    } else if (value < 0.00001) value = 0;
    style.filter = stripAlpha(filter) +
      'alpha(opacity=' + (value * 100) + ')';
    return element;
  };

  Element._attributeTranslations = {
    read: {
      names: {
        'class': 'className',
        'for':   'htmlFor'
      },
      values: {
        _getAttr: function(element, attribute) {
          return element.getAttribute(attribute, 2);
        },
        _getAttrNode: function(element, attribute) {
          var node = element.getAttributeNode(attribute);
          return node ? node.value : "";
        },
        _getEv: function(element, attribute) {
          attribute = element.getAttribute(attribute);
          return attribute ? attribute.toString().slice(23, -2) : null;
        },
        _flag: function(element, attribute) {
          return MVC.$E(element).hasAttribute(attribute) ? attribute : null;
        },
        style: function(element) {
          return element.style.cssText.toLowerCase();
        },
        title: function(element) {
          return element.title;
        }
      }
    }
  };

  Element._attributeTranslations.write = {
    names: Object.clone(Element._attributeTranslations.read.names),
    values: {
      checked: function(element, value) {
        element.checked = !!value;
      },

      style: function(element, value) {
        element.style.cssText = value ? value : '';
      }
    }
  };

  Element._attributeTranslations.has = {};

  $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
      'encType maxLength readOnly longDesc').each(function(attr) {
    Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
    Element._attributeTranslations.has[attr.toLowerCase()] = attr;
  });

  (function(v) {
    Object.extend(v, {
      href:        v._getAttr,
      src:         v._getAttr,
      type:        v._getAttr,
      action:      v._getAttrNode,
      disabled:    v._flag,
      checked:     v._flag,
      readonly:    v._flag,
      multiple:    v._flag,
      onload:      v._getEv,
      onunload:    v._getEv,
      onclick:     v._getEv,
      ondblclick:  v._getEv,
      onmousedown: v._getEv,
      onmouseup:   v._getEv,
      onmouseover: v._getEv,
      onmousemove: v._getEv,
      onmouseout:  v._getEv,
      onfocus:     v._getEv,
      onblur:      v._getEv,
      onkeypress:  v._getEv,
      onkeydown:   v._getEv,
      onkeyup:     v._getEv,
      onsubmit:    v._getEv,
      onreset:     v._getEv,
      onselect:    v._getEv,
      onchange:    v._getEv
    });
  })(Element._attributeTranslations.read.values);
}

else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
  Element.Methods.setOpacity = function(element, value) {
    element = MVC.$E(element);
    element.style.opacity = (value == 1) ? 0.999999 :
      (value === '') ? '' : (value < 0.00001) ? 0 : value;
    return element;
  };
}

else if (Prototype.Browser.WebKit) {
  Element.Methods.setOpacity = function(element, value) {
    element = MVC.$E(element);
    element.style.opacity = (value == 1 || value === '') ? '' :
      (value < 0.00001) ? 0 : value;

    if (value == 1)
      if(element.tagName == 'IMG' && element.width) {
        element.width++; element.width--;
      } else try {
        var n = document.createTextNode(' ');
        element.appendChild(n);
        element.removeChild(n);
      } catch (e) { }

    return element;
  };

  // Safari returns margins on body which is incorrect if the child is absolutely
  // positioned.  For performance reasons, redefine Element#cumulativeOffset for
  // KHTML/WebKit only.
  Element.Methods.cumulativeOffset = function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      if (element.offsetParent == document.body)
        if (Element.getStyle(element, 'position') == 'absolute') break;

      element = element.offsetParent;
    } while (element);

    return Element._returnOffset(valueL, valueT);
  };
}

if (Prototype.Browser.IE || Prototype.Browser.Opera) {
  // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements
  Element.Methods.update = function(element, content) {
    element = MVC.$E(element);

    if (content && content.toElement) content = content.toElement();
    if (Object.isElement(content)) return element.update().insert(content);

    content = Object.toHTML(content);
    var tagName = element.tagName.toUpperCase();

    if (tagName in Element._insertionTranslations.tags) {
      $A(element.childNodes).each(function(node) { element.removeChild(node) });
      Element._getContentFromAnonymousElement(tagName, content.stripScripts())
        .each(function(node) { element.appendChild(node) });
    }
    else element.innerHTML = content.stripScripts();

    content.evalScripts.bind(content).defer();
    return element;
  };
}

if (document.createElement('div').outerHTML) {
  Element.Methods.replace = function(element, content) {
    element = MVC.$E(element);

    if (content && content.toElement) content = content.toElement();
    if (Object.isElement(content)) {
      element.parentNode.replaceChild(content, element);
      return element;
    }

    content = Object.toHTML(content);
    var parent = element.parentNode, tagName = parent.tagName.toUpperCase();

    if (Element._insertionTranslations.tags[tagName]) {
      var nextSibling = element.next();
      var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
      parent.removeChild(element);
      if (nextSibling)
        fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
      else
        fragments.each(function(node) { parent.appendChild(node) });
    }
    else element.outerHTML = content.stripScripts();

    content.evalScripts.bind(content).defer();
    return element;
  };
}

Element._returnOffset = function(l, t) {
  var result = [l, t];
  result.left = l;
  result.top = t;
  return result;
};

Element._getContentFromAnonymousElement = function(tagName, html) {
  var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
  if (t) {
    div.innerHTML = t[0] + html + t[1];
    t[2].times(function() { div = div.firstChild });
  } else div.innerHTML = html;
  return $A(div.childNodes);
};

Element._insertionTranslations = {
  before: function(element, node) {
    element.parentNode.insertBefore(node, element);
  },
  top: function(element, node) {
    element.insertBefore(node, element.firstChild);
  },
  bottom: function(element, node) {
    element.appendChild(node);
  },
  after: function(element, node) {
    element.parentNode.insertBefore(node, element.nextSibling);
  },
  tags: {
    TABLE:  ['<table>',                '</table>',                   1],
    TBODY:  ['<table><tbody>',         '</tbody></table>',           2],
    TR:     ['<table><tbody><tr>',     '</tr></tbody></table>',      3],
    TD:     ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
    SELECT: ['<select>',               '</select>',                  1]
  }
};

(function() {
  Object.extend(this.tags, {
    THEAD: this.tags.TBODY,
    TFOOT: this.tags.TBODY,
    TH:    this.tags.TD
  });
}).call(Element._insertionTranslations);

Element.Methods.Simulated = {
  hasAttribute: function(element, attribute) {
    attribute = Element._attributeTranslations.has[attribute] || attribute;
    var node = MVC.$E(element).getAttributeNode(attribute);
    return node && node.specified;
  }
};

Element.Methods.ByTag = { };

Object.extend(Element, Element.Methods);

if (!Prototype.BrowserFeatures.ElementExtensions &&
    document.createElement('div').__proto__) {
  window.HTMLElement = { };
  window.HTMLElement.prototype = document.createElement('div').__proto__;
  Prototype.BrowserFeatures.ElementExtensions = true;
}

Element.extend = (function() {
  if (Prototype.BrowserFeatures.SpecificElementExtensions)
    return Prototype.K;

  var Methods = { }, ByTag = Element.Methods.ByTag;

  var extend = Object.extend(function(element) {
    if (!element || element._extendedByPrototype ||
        element.nodeType != 1 || element == window) return element;

    var methods = Object.clone(Methods),
      tagName = element.tagName, property, value;

    // extend methods for specific tags
    if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);

    for (property in methods) {
      value = methods[property];
      if (Object.isFunction(value) && !(property in element))
        element[property] = value.methodize();
    }

    element._extendedByPrototype = Prototype.emptyFunction;
    return element;

  }, {
    refresh: function() {
      // extend methods for all tags (Safari doesn't need this)
      if (!Prototype.BrowserFeatures.ElementExtensions) {
        Object.extend(Methods, Element.Methods);
        Object.extend(Methods, Element.Methods.Simulated);
      }
    }
  });

  extend.refresh();
  return extend;
})();

Element.hasAttribute = function(element, attribute) {
  if (element.hasAttribute) return element.hasAttribute(attribute);
  return Element.Methods.Simulated.hasAttribute(element, attribute);
};

Element.addMethods = function(methods) {
  var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;

  if (!methods) {
    Object.extend(Form, Form.Methods);
    Object.extend(Form.Element, Form.Element.Methods);
    Object.extend(Element.Methods.ByTag, {
      "FORM":     Object.clone(Form.Methods),
      "INPUT":    Object.clone(Form.Element.Methods),
      "SELECT":   Object.clone(Form.Element.Methods),
      "TEXTAREA": Object.clone(Form.Element.Methods)
    });
  }

  if (arguments.length == 2) {
    var tagName = methods;
    methods = arguments[1];
  }

  if (!tagName) Object.extend(Element.Methods, methods || { });
  else {
    if (Object.isArray(tagName)) tagName.each(extend);
    else extend(tagName);
  }

  function extend(tagName) {
    tagName = tagName.toUpperCase();
    if (!Element.Methods.ByTag[tagName])
      Element.Methods.ByTag[tagName] = { };
    Object.extend(Element.Methods.ByTag[tagName], methods);
  }

  function copy(methods, destination, onlyIfAbsent) {
    onlyIfAbsent = onlyIfAbsent || false;
    for (var property in methods) {
      var value = methods[property];
      if (!Object.isFunction(value)) continue;
      if (!onlyIfAbsent || !(property in destination))
        destination[property] = value.methodize();
    }
  }

  function findDOMClass(tagName) {
    var klass;
    var trans = {
      "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
      "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
      "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
      "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
      "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
      "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
      "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
      "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
      "FrameSet", "IFRAME": "IFrame"
    };
    if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
    if (window[klass]) return window[klass];
    klass = 'HTML' + tagName + 'Element';
    if (window[klass]) return window[klass];
    klass = 'HTML' + tagName.capitalize() + 'Element';
    if (window[klass]) return window[klass];

    window[klass] = { };
    window[klass].prototype = document.createElement(tagName).__proto__;
    return window[klass];
  }

  if (F.ElementExtensions) {
    copy(Element.Methods, HTMLElement.prototype);
    copy(Element.Methods.Simulated, HTMLElement.prototype, true);
  }

  if (F.SpecificElementExtensions) {
    for (var tag in Element.Methods.ByTag) {
      var klass = findDOMClass(tag);
      if (Object.isUndefined(klass)) continue;
      copy(T[tag], klass.prototype);
    }
  }

  Object.extend(Element, Element.Methods);
  delete Element.ByTag;

  if (Element.extend.refresh) Element.extend.refresh();
  Element.cache = { };
};

document.viewport = {
  getDimensions: function() {
    var dimensions = { };
    var B = Prototype.Browser;
    $w('width height').each(function(d) {
      var D = d.capitalize();
      dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] :
        (B.Opera) ? document.body['client' + D] : document.documentElement['client' + D];
    });
    return dimensions;
  },

  getWidth: function() {
    return this.getDimensions().width;
  },

  getHeight: function() {
    return this.getDimensions().height;
  },

  getScrollOffsets: function() {
    return Element._returnOffset(
      window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
      window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
  }
};
/* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
 * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
 * license.  Please see http://www.yui-ext.com/ for more information. */

var Selector = Class.create({
  initialize: function(expression) {
    this.expression = expression.strip();
    this.compileMatcher();
  },

  shouldUseXPath: function() {
    if (!Prototype.BrowserFeatures.XPath) return false;

    var e = this.expression;

    // Safari 3 chokes on :*-of-type and :empty
    if (Prototype.Browser.WebKit &&
     (e.include("-of-type") || e.include(":empty")))
      return false;

    // XPath can't do namespaced attributes, nor can it read
    // the "checked" property from DOM nodes
    if ((/(\[[\w-]*?:|:checked)/).test(this.expression))
      return false;

    return true;
  },

  compileMatcher: function() {
    if (this.shouldUseXPath())
      return this.compileXPathMatcher();

    var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
        c = Selector.criteria, le, p, m;

    if (Selector._cache[e]) {
      this.matcher = Selector._cache[e];
      return;
    }

    this.matcher = ["this.matcher = function(root) {",
                    "var r = root, h = Selector.handlers, c = false, n;"];

    while (e && le != e && (/\S/).test(e)) {
      le = e;
      for (var i in ps) {
        p = ps[i];
        if (m = e.match(p)) {
          this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
    	      new Template(c[i]).evaluate(m));
          e = e.replace(m[0], '');
          break;
        }
      }
    }

    this.matcher.push("return h.unique(n);\n}");
    eval(this.matcher.join('\n'));
    Selector._cache[this.expression] = this.matcher;
  },

  compileXPathMatcher: function() {
    var e = this.expression, ps = Selector.patterns,
        x = Selector.xpath, le, m;

    if (Selector._cache[e]) {
      this.xpath = Selector._cache[e]; return;
    }

    this.matcher = ['.//*'];
    while (e && le != e && (/\S/).test(e)) {
      le = e;
      for (var i in ps) {
        if (m = e.match(ps[i])) {
          this.matcher.push(Object.isFunction(x[i]) ? x[i](m) :
            new Template(x[i]).evaluate(m));
          e = e.replace(m[0], '');
          break;
        }
      }
    }

    this.xpath = this.matcher.join('');
    Selector._cache[this.expression] = this.xpath;
  },

  findElements: function(root) {
    root = root || document;
    if (this.xpath) return document._getElementsByXPath(this.xpath, root);
    return this.matcher(root);
  },

  match: function(element) {
    this.tokens = [];

    var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
    var le, p, m;

    while (e && le !== e && (/\S/).test(e)) {
      le = e;
      for (var i in ps) {
        p = ps[i];
        if (m = e.match(p)) {
          // use the Selector.assertions methods unless the selector
          // is too complex.
          if (as[i]) {
            this.tokens.push([i, Object.clone(m)]);
            e = e.replace(m[0], '');
          } else {
            // reluctantly do a document-wide search
            // and look for a match in the array
            return this.findElements(document).include(element);
          }
        }
      }
    }

    var match = true, name, matches;
    for (var i = 0, token; token = this.tokens[i]; i++) {
      name = token[0], matches = token[1];
      if (!Selector.assertions[name](element, matches)) {
        match = false; break;
      }
    }

    return match;
  },

  toString: function() {
    return this.expression;
  },

  inspect: function() {
    return "#<Selector:" + this.expression.inspect() + ">";
  }
});

Object.extend(Selector, {
  _cache: { },

  xpath: {
    descendant:   "//*",
    child:        "/*",
    adjacent:     "/following-sibling::*[1]",
    laterSibling: '/following-sibling::*',
    tagName:      function(m) {
      if (m[1] == '*') return '';
      return "[local-name()='" + m[1].toLowerCase() +
             "' or local-name()='" + m[1].toUpperCase() + "']";
    },
    className:    "[contains(concat(' ', @class, ' '), ' #{1} ')]",
    id:           "[@id='#{1}']",
    attrPresence: function(m) {
      m[1] = m[1].toLowerCase();
      return new Template("[@#{1}]").evaluate(m);
    },
    attr: function(m) {
      m[1] = m[1].toLowerCase();
      m[3] = m[5] || m[6];
      return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
    },
    pseudo: function(m) {
      var h = Selector.xpath.pseudos[m[1]];
      if (!h) return '';
      if (Object.isFunction(h)) return h(m);
      return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
    },
    operators: {
      '=':  "[@#{1}='#{3}']",
      '!=': "[@#{1}!='#{3}']",
      '^=': "[starts-with(@#{1}, '#{3}')]",
      '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
      '*=': "[contains(@#{1}, '#{3}')]",
      '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
      '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
    },
    pseudos: {
      'first-child': '[not(preceding-sibling::*)]',
      'last-child':  '[not(following-sibling::*)]',
      'only-child':  '[not(preceding-sibling::* or following-sibling::*)]',
      'empty':       "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",
      'checked':     "[@checked]",
      'disabled':    "[@disabled]",
      'enabled':     "[not(@disabled)]",
      'not': function(m) {
        var e = m[6], p = Selector.patterns,
            x = Selector.xpath, le, v;

        var exclusion = [];
        while (e && le != e && (/\S/).test(e)) {
          le = e;
          for (var i in p) {
            if (m = e.match(p[i])) {
              v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m);
              exclusion.push("(" + v.substring(1, v.length - 1) + ")");
              e = e.replace(m[0], '');
              break;
            }
          }
        }
        return "[not(" + exclusion.join(" and ") + ")]";
      },
      'nth-child':      function(m) {
        return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
      },
      'nth-last-child': function(m) {
        return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
      },
      'nth-of-type':    function(m) {
        return Selector.xpath.pseudos.nth("position() ", m);
      },
      'nth-last-of-type': function(m) {
        return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
      },
      'first-of-type':  function(m) {
        m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
      },
      'last-of-type':   function(m) {
        m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
      },
      'only-of-type':   function(m) {
        var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
      },
      nth: function(fragment, m) {
        var mm, formula = m[6], predicate;
        if (formula == 'even') formula = '2n+0';
        if (formula == 'odd')  formula = '2n+1';
        if (mm = formula.match(/^(\d+)$/)) // digit only
          return '[' + fragment + "= " + mm[1] + ']';
        if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
          if (mm[1] == "-") mm[1] = -1;
          var a = mm[1] ? Number(mm[1]) : 1;
          var b = mm[2] ? Number(mm[2]) : 0;
          predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
          "((#{fragment} - #{b}) div #{a} >= 0)]";
          return new Template(predicate).evaluate({
            fragment: fragment, a: a, b: b });
        }
      }
    }
  },

  criteria: {
    tagName:      'n = h.tagName(n, r, "#{1}", c);   c = false;',
    className:    'n = h.className(n, r, "#{1}", c); c = false;',
    id:           'n = h.id(n, r, "#{1}", c);        c = false;',
    attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;',
    attr: function(m) {
      m[3] = (m[5] || m[6]);
      return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m);
    },
    pseudo: function(m) {
      if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
      return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
    },
    descendant:   'c = "descendant";',
    child:        'c = "child";',
    adjacent:     'c = "adjacent";',
    laterSibling: 'c = "laterSibling";'
  },

  patterns: {
    // combinators must be listed first
    // (and descendant needs to be last combinator)
    laterSibling: /^\s*~\s*/,
    child:        /^\s*>\s*/,
    adjacent:     /^\s*\+\s*/,
    descendant:   /^\s/,

    // selectors follow
    tagName:      /^\s*(\*|[\w\-]+)(\b|$)?/,
    id:           /^#([\w\-\*]+)(\b|$)/,
    className:    /^\.([\w\-\*]+)(\b|$)/,
    pseudo:
/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,
    attrPresence: /^\[([\w]+)\]/,
    attr:         /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
  },

  // for Selector.match and Element#match
  assertions: {
    tagName: function(element, matches) {
      return matches[1].toUpperCase() == element.tagName.toUpperCase();
    },

    className: function(element, matches) {
      return Element.hasClassName(element, matches[1]);
    },

    id: function(element, matches) {
      return element.id === matches[1];
    },

    attrPresence: function(element, matches) {
      return Element.hasAttribute(element, matches[1]);
    },

    attr: function(element, matches) {
      var nodeValue = Element.readAttribute(element, matches[1]);
      return Selector.operators[matches[2]](nodeValue, matches[3]);
    }
  },

  handlers: {
    // UTILITY FUNCTIONS
    // joins two collections
    concat: function(a, b) {
      for (var i = 0, node; node = b[i]; i++)
        a.push(node);
      return a;
    },

    // marks an array of nodes for counting
    mark: function(nodes) {
      for (var i = 0, node; node = nodes[i]; i++)
        node._counted = true;
      return nodes;
    },

    unmark: function(nodes) {
      for (var i = 0, node; node = nodes[i]; i++)
        node._counted = undefined;
      return nodes;
    },

    // mark each child node with its position (for nth calls)
    // "ofType" flag indicates whether we're indexing for nth-of-type
    // rather than nth-child
    index: function(parentNode, reverse, ofType) {
      parentNode._counted = true;
      if (reverse) {
        for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
          var node = nodes[i];
          if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
        }
      } else {
        for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
          if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
      }
    },

    // filters out duplicates and extends all nodes
    unique: function(nodes) {
      if (nodes.length == 0) return nodes;
      var results = [], n;
      for (var i = 0, l = nodes.length; i < l; i++)
        if (!(n = nodes[i])._counted) {
          n._counted = true;
          results.push(Element.extend(n));
        }
      return Selector.handlers.unmark(results);
    },

    // COMBINATOR FUNCTIONS
    descendant: function(nodes) {
      var h = Selector.handlers;
      for (var i = 0, results = [], node; node = nodes[i]; i++)
        h.concat(results, node.getElementsByTagName('*'));
      return results;
    },

    child: function(nodes) {
      var h = Selector.handlers;
      for (var i = 0, results = [], node; node = nodes[i]; i++) {
        for (var j = 0, child; child = node.childNodes[j]; j++)
          if (child.nodeType == 1 && child.tagName != '!') results.push(child);
      }
      return results;
    },

    adjacent: function(nodes) {
      for (var i = 0, results = [], node; node = nodes[i]; i++) {
        var next = this.nextElementSibling(node);
        if (next) results.push(next);
      }
      return results;
    },

    laterSibling: function(nodes) {
      var h = Selector.handlers;
      for (var i = 0, results = [], node; node = nodes[i]; i++)
        h.concat(results, Element.nextSiblings(node));
      return results;
    },

    nextElementSibling: function(node) {
      while (node = node.nextSibling)
	      if (node.nodeType == 1) return node;
      return null;
    },

    previousElementSibling: function(node) {
      while (node = node.previousSibling)
        if (node.nodeType == 1) return node;
      return null;
    },

    // TOKEN FUNCTIONS
    tagName: function(nodes, root, tagName, combinator) {
      var uTagName = tagName.toUpperCase();
      var results = [], h = Selector.handlers;
      if (nodes) {
        if (combinator) {
          // fastlane for ordinary descendant combinators
          if (combinator == "descendant") {
            for (var i = 0, node; node = nodes[i]; i++)
              h.concat(results, node.getElementsByTagName(tagName));
            return results;
          } else nodes = this[combinator](nodes);
          if (tagName == "*") return nodes;
        }
        for (var i = 0, node; node = nodes[i]; i++)
          if (node.tagName.toUpperCase() === uTagName) results.push(node);
        return results;
      } else return root.getElementsByTagName(tagName);
    },

    id: function(nodes, root, id, combinator) {
      var targetNode = MVC.$E(id), h = Selector.handlers;
      if (!targetNode) return [];
      if (!nodes && root == document) return [targetNode];
      if (nodes) {
        if (combinator) {
          if (combinator == 'child') {
            for (var i = 0, node; node = nodes[i]; i++)
              if (targetNode.parentNode == node) return [targetNode];
          } else if (combinator == 'descendant') {
            for (var i = 0, node; node = nodes[i]; i++)
              if (Element.descendantOf(targetNode, node)) return [targetNode];
          } else if (combinator == 'adjacent') {
            for (var i = 0, node; node = nodes[i]; i++)
              if (Selector.handlers.previousElementSibling(targetNode) == node)
                return [targetNode];
          } else nodes = h[combinator](nodes);
        }
        for (var i = 0, node; node = nodes[i]; i++)
          if (node == targetNode) return [targetNode];
        return [];
      }
      return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
    },

    className: function(nodes, root, className, combinator) {
      if (nodes && combinator) nodes = this[combinator](nodes);
      return Selector.handlers.byClassName(nodes, root, className);
    },

    byClassName: function(nodes, root, className) {
      if (!nodes) nodes = Selector.handlers.descendant([root]);
      var needle = ' ' + className + ' ';
      for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
        nodeClassName = node.className;
        if (nodeClassName.length == 0) continue;
        if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
          results.push(node);
      }
      return results;
    },

    attrPresence: function(nodes, root, attr) {
      if (!nodes) nodes = root.getElementsByTagName("*");
      var results = [];
      for (var i = 0, node; node = nodes[i]; i++)
        if (Element.hasAttribute(node, attr)) results.push(node);
      return results;
    },

    attr: function(nodes, root, attr, value, operator) {
      if (!nodes) nodes = root.getElementsByTagName("*");
      var handler = Selector.operators[operator], results = [];
      for (var i = 0, node; node = nodes[i]; i++) {
        var nodeValue = Element.readAttribute(node, attr);
        if (nodeValue === null) continue;
        if (handler(nodeValue, value)) results.push(node);
      }
      return results;
    },

    pseudo: function(nodes, name, value, root, combinator) {
      if (nodes && combinator) nodes = this[combinator](nodes);
      if (!nodes) nodes = root.getElementsByTagName("*");
      return Selector.pseudos[name](nodes, value, root);
    }
  },

  pseudos: {
    'first-child': function(nodes, value, root) {
      for (var i = 0, results = [], node; node = nodes[i]; i++) {
        if (Selector.handlers.previousElementSibling(node)) continue;
          results.push(node);
      }
      return results;
    },
    'last-child': function(nodes, value, root) {
      for (var i = 0, results = [], node; node = nodes[i]; i++) {
        if (Selector.handlers.nextElementSibling(node)) continue;
          results.push(node);
      }
      return results;
    },
    'only-child': function(nodes, value, root) {
      var h = Selector.handlers;
      for (var i = 0, results = [], node; node = nodes[i]; i++)
        if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
          results.push(node);
      return results;
    },
    'nth-child':        function(nodes, formula, root) {
      return Selector.pseudos.nth(nodes, formula, root);
    },
    'nth-last-child':   function(nodes, formula, root) {
      return Selector.pseudos.nth(nodes, formula, root, true);
    },
    'nth-of-type':      function(nodes, formula, root) {
      return Selector.pseudos.nth(nodes, formula, root, false, true);
    },
    'nth-last-of-type': function(nodes, formula, root) {
      return Selector.pseudos.nth(nodes, formula, root, true, true);
    },
    'first-of-type':    function(nodes, formula, root) {
      return Selector.pseudos.nth(nodes, "1", root, false, true);
    },
    'last-of-type':     function(nodes, formula, root) {
      return Selector.pseudos.nth(nodes, "1", root, true, true);
    },
    'only-of-type':     function(nodes, formula, root) {
      var p = Selector.pseudos;
      return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
    },

    // handles the an+b logic
    getIndices: function(a, b, total) {
      if (a == 0) return b > 0 ? [b] : [];
      return $R(1, total).inject([], function(memo, i) {
        if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
        return memo;
      });
    },

    // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
    nth: function(nodes, formula, root, reverse, ofType) {
      if (nodes.length == 0) return [];
      if (formula == 'even') formula = '2n+0';
      if (formula == 'odd')  formula = '2n+1';
      var h = Selector.handlers, results = [], indexed = [], m;
      h.mark(nodes);
      for (var i = 0, node; node = nodes[i]; i++) {
        if (!node.parentNode._counted) {
          h.index(node.parentNode, reverse, ofType);
          indexed.push(node.parentNode);
        }
      }
      if (formula.match(/^\d+$/)) { // just a number
        formula = Number(formula);
        for (var i = 0, node; node = nodes[i]; i++)
          if (node.nodeIndex == formula) results.push(node);
      } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
        if (m[1] == "-") m[1] = -1;
        var a = m[1] ? Number(m[1]) : 1;
        var b = m[2] ? Number(m[2]) : 0;
        var indices = Selector.pseudos.getIndices(a, b, nodes.length);
        for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
          for (var j = 0; j < l; j++)
            if (node.nodeIndex == indices[j]) results.push(node);
        }
      }
      h.unmark(nodes);
      h.unmark(indexed);
      return results;
    },

    'empty': function(nodes, value, root) {
      for (var i = 0, results = [], node; node = nodes[i]; i++) {
        // IE treats comments as element nodes
        if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
        results.push(node);
      }
      return results;
    },

    'not': function(nodes, selector, root) {
      var h = Selector.handlers, selectorType, m;
      var exclusions = new Selector(selector).findElements(root);
      h.mark(exclusions);
      for (var i = 0, results = [], node; node = nodes[i]; i++)
        if (!node._counted) results.push(node);
      h.unmark(exclusions);
      return results;
    },

    'enabled': function(nodes, value, root) {
      for (var i = 0, results = [], node; node = nodes[i]; i++)
        if (!node.disabled) results.push(node);
      return results;
    },

    'disabled': function(nodes, value, root) {
      for (var i = 0, results = [], node; node = nodes[i]; i++)
        if (node.disabled) results.push(node);
      return results;
    },

    'checked': function(nodes, value, root) {
      for (var i = 0, results = [], node; node = nodes[i]; i++)
        if (node.checked) results.push(node);
      return results;
    }
  },

  operators: {
    '=':  function(nv, v) { return nv == v; },
    '!=': function(nv, v) { return nv != v; },
    '^=': function(nv, v) { return nv.startsWith(v); },
    '$=': function(nv, v) { return nv.endsWith(v); },
    '*=': function(nv, v) { return nv.include(v); },
    '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
    '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
  },

  matchElements: function(elements, expression) {
    var matches = new Selector(expression).findElements(), h = Selector.handlers;
    h.mark(matches);
    for (var i = 0, results = [], element; element = elements[i]; i++)
      if (element._counted) results.push(element);
    h.unmark(matches);
    return results;
  },

  findElement: function(elements, expression, index) {
    if (Object.isNumber(expression)) {
      index = expression; expression = false;
    }
    return Selector.matchElements(elements, expression || '*')[index || 0];
  },

  findChildElements: function(element, expressions) {
    var exprs = expressions.join(',');
    expressions = [];
    exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
      expressions.push(m[1].strip());
    });
    var results = [], h = Selector.handlers;
    for (var i = 0, l = expressions.length, selector; i < l; i++) {
      selector = new Selector(expressions[i].strip());
      h.concat(results, selector.findElements(element));
    }
    return (l > 1) ? h.unique(results) : results;
  }
});

if (Prototype.Browser.IE) {
  // IE returns comment nodes on getElementsByTagName("*").
  // Filter them out.
  Selector.handlers.concat = function(a, b) {
    for (var i = 0, node; node = b[i]; i++)
      if (node.tagName !== "!") a.push(node);
    return a;
  };
}

function $MVC.$E() {
  return Selector.findChildElements(document, $A(arguments));
}
var Form = {
  reset: function(form) {
    MVC.$E(form).reset();
    return form;
  },

  serializeElements: function(elements, options) {
    if (typeof options != 'object') options = { hash: !!options };
    else if (Object.isUndefined(options.hash)) options.hash = true;
    var key, value, submitted = false, submit = options.submit;

    var data = elements.inject({ }, function(result, element) {
      if (!element.disabled && element.name) {
        key = element.name; value = MVC.$E(element).getValue();
        if (value != null && (element.type != 'submit' || (!submitted &&
            submit !== false && (!submit || key == submit) && (submitted = true)))) {
          if (key in result) {
            // a key is already present; construct an array of values
            if (!Object.isArray(result[key])) result[key] = [result[key]];
            result[key].push(value);
          }
          else result[key] = value;
        }
      }
      return result;
    });

    return options.hash ? data : Object.toQueryString(data);
  }
};

Form.Methods = {
  serialize: function(form, options) {
    return Form.serializeElements(Form.getElements(form), options);
  },

  getElements: function(form) {
    return $A(MVC.$E(form).getElementsByTagName('*')).inject([],
      function(elements, child) {
        if (Form.Element.Serializers[child.tagName.toLowerCase()])
          elements.push(Element.extend(child));
        return elements;
      }
    );
  },

  getInputs: function(form, typeName, name) {
    form = MVC.$E(form);
    var inputs = form.getElementsByTagName('input');

    if (!typeName && !name) return $A(inputs).map(Element.extend);

    for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
      var input = inputs[i];
      if ((typeName && input.type != typeName) || (name && input.name != name))
        continue;
      matchingInputs.push(Element.extend(input));
    }

    return matchingInputs;
  },

  disable: function(form) {
    form = MVC.$E(form);
    Form.getElements(form).invoke('disable');
    return form;
  },

  enable: function(form) {
    form = MVC.$E(form);
    Form.getElements(form).invoke('enable');
    return form;
  },

  findFirstElement: function(form) {
    var elements = MVC.$E(form).getElements().findAll(function(element) {
      return 'hidden' != element.type && !element.disabled;
    });
    var firstByIndex = elements.findAll(function(element) {
      return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
    }).sortBy(function(element) { return element.tabIndex }).first();

    return firstByIndex ? firstByIndex : elements.find(function(element) {
      return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
    });
  },

  focusFirstElement: function(form) {
    form = MVC.$E(form);
    form.findFirstElement().activate();
    return form;
  },

  request: function(form, options) {
    form = MVC.$E(form), options = Object.clone(options || { });

    var params = options.parameters, action = form.readAttribute('action') || '';
    if (action.blank()) action = window.location.href;
    options.parameters = form.serialize(true);

    if (params) {
      if (Object.isString(params)) params = params.toQueryParams();
      Object.extend(options.parameters, params);
    }

    if (form.hasAttribute('method') && !options.method)
      options.method = form.method;

    return new Ajax.Request(action, options);
  }
};

/*--------------------------------------------------------------------------*/

Form.Element = {
  focus: function(element) {
    MVC.$E(element).focus();
    return element;
  },

  select: function(element) {
    MVC.$E(element).select();
    return element;
  }
};

Form.Element.Methods = {
  serialize: function(element) {
    element = MVC.$E(element);
    if (!element.disabled && element.name) {
      var value = element.getValue();
      if (value != undefined) {
        var pair = { };
        pair[element.name] = value;
        return Object.toQueryString(pair);
      }
    }
    return '';
  },

  getValue: function(element) {
    element = MVC.$E(element);
    var method = element.tagName.toLowerCase();
    return Form.Element.Serializers[method](element);
  },

  setValue: function(element, value) {
    element = MVC.$E(element);
    var method = element.tagName.toLowerCase();
    Form.Element.Serializers[method](element, value);
    return element;
  },

  clear: function(element) {
    MVC.$E(element).value = '';
    return element;
  },

  present: function(element) {
    return MVC.$E(element).value != '';
  },

  activate: function(element) {
    element = MVC.$E(element);
    try {
      element.focus();
      if (element.select && (element.tagName.toLowerCase() != 'input' ||
          !['button', 'reset', 'submit'].include(element.type)))
        element.select();
    } catch (e) { }
    return element;
  },

  disable: function(element) {
    element = MVC.$E(element);
    element.blur();
    element.disabled = true;
    return element;
  },

  enable: function(element) {
    element = MVC.$E(element);
    element.disabled = false;
    return element;
  }
};

/*--------------------------------------------------------------------------*/

var Field = Form.Element;
var $F = Form.Element.Methods.getValue;

/*--------------------------------------------------------------------------*/

Form.Element.Serializers = {
  input: function(element, value) {
    switch (element.type.toLowerCase()) {
      case 'checkbox':
      case 'radio':
        return Form.Element.Serializers.inputSelector(element, value);
      default:
        return Form.Element.Serializers.textarea(element, value);
    }
  },

  inputSelector: function(element, value) {
    if (Object.isUndefined(value)) return element.checked ? element.value : null;
    else element.checked = !!value;
  },

  textarea: function(element, value) {
    if (Object.isUndefined(value)) return element.value;
    else element.value = value;
  },

  select: function(element, index) {
    if (Object.isUndefined(index))
      return this[element.type == 'select-one' ?
        'selectOne' : 'selectMany'](element);
    else {
      var opt, value, single = !Object.isArray(index);
      for (var i = 0, length = element.length; i < length; i++) {
        opt = element.options[i];
        value = this.optionValue(opt);
        if (single) {
          if (value == index) {
            opt.selected = true;
            return;
          }
        }
        else opt.selected = index.include(value);
      }
    }
  },

  selectOne: function(element) {
    var index = element.selectedIndex;
    return index >= 0 ? this.optionValue(element.options[index]) : null;
  },

  selectMany: function(element) {
    var values, length = element.length;
    if (!length) return null;

    for (var i = 0, values = []; i < length; i++) {
      var opt = element.options[i];
      if (opt.selected) values.push(this.optionValue(opt));
    }
    return values;
  },

  optionValue: function(opt) {
    // extend element because hasAttribute may not be native
    return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
  }
};

/*--------------------------------------------------------------------------*/

Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
  initialize: function($super, element, frequency, callback) {
    $super(callback, frequency);
    this.element   = MVC.$E(element);
    this.lastValue = this.getValue();
  },

  execute: function() {
    var value = this.getValue();
    if (Object.isString(this.lastValue) && Object.isString(value) ?
        this.lastValue != value : String(this.lastValue) != String(value)) {
      this.callback(this.element, value);
      this.lastValue = value;
    }
  }
});

Form.Element.Observer = Class.create(Abstract.TimedObserver, {
  getValue: function() {
    return Form.Element.getValue(this.element);
  }
});

Form.Observer = Class.create(Abstract.TimedObserver, {
  getValue: function() {
    return Form.serialize(this.element);
  }
});

/*--------------------------------------------------------------------------*/

Abstract.EventObserver = Class.create({
  initialize: function(element, callback) {
    this.element  = MVC.$E(element);
    this.callback = callback;

    this.lastValue = this.getValue();
    if (this.element.tagName.toLowerCase() == 'form')
      this.registerFormCallbacks();
    else
      this.registerCallback(this.element);
  },

  onElementEvent: function() {
    var value = this.getValue();
    if (this.lastValue != value) {
      this.callback(this.element, value);
      this.lastValue = value;
    }
  },

  registerFormCallbacks: function() {
    Form.getElements(this.element).each(this.registerCallback, this);
  },

  registerCallback: function(element) {
    if (element.type) {
      switch (element.type.toLowerCase()) {
        case 'checkbox':
        case 'radio':
          Event.observe(element, 'click', this.onElementEvent.bind(this));
          break;
        default:
          Event.observe(element, 'change', this.onElementEvent.bind(this));
          break;
      }
    }
  }
});

Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
  getValue: function() {
    return Form.Element.getValue(this.element);
  }
});

Form.EventObserver = Class.create(Abstract.EventObserver, {
  getValue: function() {
    return Form.serialize(this.element);
  }
});
if (!window.Event) var Event = { };

Object.extend(Event, {
  KEY_BACKSPACE: 8,
  KEY_TAB:       9,
  KEY_RETURN:   13,
  KEY_ESC:      27,
  KEY_LEFT:     37,
  KEY_UP:       38,
  KEY_RIGHT:    39,
  KEY_DOWN:     40,
  KEY_DELETE:   46,
  KEY_HOME:     36,
  KEY_END:      35,
  KEY_PAGEUP:   33,
  KEY_PAGEDOWN: 34,
  KEY_INSERT:   45,

  cache: { },

  relatedTarget: function(event) {
    var element;
    switch(event.type) {
      case 'mouseover': element = event.fromElement; break;
      case 'mouseout':  element = event.toElement;   break;
      default: return null;
    }
    return Element.extend(element);
  }
});

Event.Methods = (function() {
  var isButton;

  if (Prototype.Browser.IE) {
    var buttonMap = { 0: 1, 1: 4, 2: 2 };
    isButton = function(event, code) {
      return event.button == buttonMap[code];
    };

  } else if (Prototype.Browser.WebKit) {
    isButton = function(event, code) {
      switch (code) {
        case 0: return event.which == 1 && !event.metaKey;
        case 1: return event.which == 1 && event.metaKey;
        default: return false;
      }
    };

  } else {
    isButton = function(event, code) {
      return event.which ? (event.which === code + 1) : (event.button === code);
    };
  }

  return {
    isLeftClick:   function(event) { return isButton(event, 0) },
    isMiddleClick: function(event) { return isButton(event, 1) },
    isRightClick:  function(event) { return isButton(event, 2) },

    element: function(event) {
      var node = Event.extend(event).target;
      return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
    },

    findElement: function(event, expression) {
      var element = Event.element(event);
      if (!expression) return element;
      var elements = [element].concat(element.ancestors());
      return Selector.findElement(elements, expression, 0);
    },

    pointer: function(event) {
      return {
        x: event.pageX || (event.clientX +
          (document.documentElement.scrollLeft || document.body.scrollLeft)),
        y: event.pageY || (event.clientY +
          (document.documentElement.scrollTop || document.body.scrollTop))
      };
    },

    pointerX: function(event) { return Event.pointer(event).x },
    pointerY: function(event) { return Event.pointer(event).y },

    stop: function(event) {
      Event.extend(event);
      event.preventDefault();
      event.stopPropagation();
      event.stopped = true;
    }
  };
})();

Event.extend = (function() {
  var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
    m[name] = Event.Methods[name].methodize();
    return m;
  });

  if (Prototype.Browser.IE) {
    Object.extend(methods, {
      stopPropagation: function() { this.cancelBubble = true },
      preventDefault:  function() { this.returnValue = false },
      inspect: function() { return "[object Event]" }
    });

    return function(event) {
      if (!event) return false;
      if (event._extendedByPrototype) return event;

      event._extendedByPrototype = Prototype.emptyFunction;
      var pointer = Event.pointer(event);
      Object.extend(event, {
        target: event.srcElement,
        relatedTarget: Event.relatedTarget(event),
        pageX:  pointer.x,
        pageY:  pointer.y
      });
      return Object.extend(event, methods);
    };

  } else {
    Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__;
    Object.extend(Event.prototype, methods);
    return Prototype.K;
  }
})();

Object.extend(Event, (function() {
  var cache = Event.cache;

  function getEventID(element) {
    if (element._eventID) return element._eventID;
    arguments.callee.id = arguments.callee.id || 1;
    return element._eventID = ++arguments.callee.id;
  }

  function getDOMEventName(eventName) {
    if (eventName && eventName.include(':')) return "dataavailable";
    return eventName;
  }

  function getCacheForID(id) {
    return cache[id] = cache[id] || { };
  }

  function getWrappersForEventName(id, eventName) {
    var c = getCacheForID(id);
    return c[eventName] = c[eventName] || [];
  }

  function createWrapper(element, eventName, handler) {
    var id = getEventID(element);
    var c = getWrappersForEventName(id, eventName);
    if (c.pluck("handler").include(handler)) return false;

    var wrapper = function(event) {
      if (!Event || !Event.extend ||
        (event.eventName && event.eventName != eventName))
          return false;

      Event.extend(event);
      handler.call(element, event);
    };

    wrapper.handler = handler;
    c.push(wrapper);
    return wrapper;
  }

  function findWrapper(id, eventName, handler) {
    var c = getWrappersForEventName(id, eventName);
    return c.find(function(wrapper) { return wrapper.handler == handler });
  }

  function destroyWrapper(id, eventName, handler) {
    var c = getCacheForID(id);
    if (!c[eventName]) return false;
    c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
  }

  function destroyCache() {
    for (var id in cache)
      for (var eventName in cache[id])
        cache[id][eventName] = null;
  }

  if (window.attachEvent) {
    window.attachEvent("onunload", destroyCache);
  }

  return {
    observe: function(element, eventName, handler) {
      element = MVC.$E(element);
      var name = getDOMEventName(eventName);

      var wrapper = createWrapper(element, eventName, handler);
      if (!wrapper) return element;

      if (element.addEventListener) {
        element.addEventListener(name, wrapper, false);
      } else {
        element.attachEvent("on" + name, wrapper);
      }

      return element;
    },

    stopObserving: function(element, eventName, handler) {
      element = MVC.$E(element);
      var id = getEventID(element), name = getDOMEventName(eventName);

      if (!handler && eventName) {
        getWrappersForEventName(id, eventName).each(function(wrapper) {
          element.stopObserving(eventName, wrapper.handler);
        });
        return element;

      } else if (!eventName) {
        Object.keys(getCacheForID(id)).each(function(eventName) {
          element.stopObserving(eventName);
        });
        return element;
      }

      var wrapper = findWrapper(id, eventName, handler);
      if (!wrapper) return element;

      if (element.removeEventListener) {
        element.removeEventListener(name, wrapper, false);
      } else {
        element.detachEvent("on" + name, wrapper);
      }

      destroyWrapper(id, eventName, handler);

      return element;
    },

    fire: function(element, eventName, memo) {
      element = MVC.$E(element);
      if (element == document && document.createEvent && !element.dispatchEvent)
        element = document.documentElement;

      var event;
      if (document.createEvent) {
        event = document.createEvent("HTMLEvents");
        event.initEvent("dataavailable", true, true);
      } else {
        event = document.createEventObject();
        event.eventType = "ondataavailable";
      }

      event.eventName = eventName;
      event.memo = memo || { };

      if (document.createEvent) {
        element.dispatchEvent(event);
      } else {
        element.fireEvent(event.eventType, event);
      }

      return Event.extend(event);
    }
  };
})());

Object.extend(Event, Event.Methods);

Element.addMethods({
  fire:          Event.fire,
  observe:       Event.observe,
  stopObserving: Event.stopObserving
});

Object.extend(document, {
  fire:          Element.Methods.fire.methodize(),
  observe:       Element.Methods.observe.methodize(),
  stopObserving: Element.Methods.stopObserving.methodize(),
  loaded:        false
});

(function() {
  /* Support for the DOMContentLoaded event is based on work by Dan Webb,
     Matthias Miller, Dean Edwards and John Resig. */

  var timer;

  function fireContentLoadedEvent() {
    if (document.loaded) return;
    if (timer) window.clearInterval(timer);
    document.fire("dom:loaded");
    document.loaded = true;
  }

  if (document.addEventListener) {
    if (Prototype.Browser.WebKit) {
      timer = window.setInterval(function() {
        if (/loaded|complete/.test(document.readyState))
          fireContentLoadedEvent();
      }, 0);

      Event.observe(window, "load", fireContentLoadedEvent);

    } else {
      document.addEventListener("DOMContentLoaded",
        fireContentLoadedEvent, false);
    }

  } else {
    document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
    MVC.$E("__onDOMContentLoaded").onreadystatechange = function() {
      if (this.readyState == "complete") {
        this.onreadystatechange = null;
        fireContentLoadedEvent();
      }
    };
  }
})();
/*------------------------------- DEPRECATED -------------------------------*/

Hash.toQueryString = Object.toQueryString;

var Toggle = { display: Element.toggle };

Element.Methods.childOf = Element.Methods.descendantOf;

var Insertion = {
  Before: function(element, content) {
    return Element.insert(element, {before:content});
  },

  Top: function(element, content) {
    return Element.insert(element, {top:content});
  },

  Bottom: function(element, content) {
    return Element.insert(element, {bottom:content});
  },

  After: function(element, content) {
    return Element.insert(element, {after:content});
  }
};

var $continue = new Error('"throw $continue" is deprecated, use "return" instead');

// This should be moved to script.aculo.us; notice the deprecated methods
// further below, that map to the newer Element methods.
var Position = {
  // set to true if needed, warning: firefox performance problems
  // NOT neeeded for page scrolling, only if draggable contained in
  // scrollable elements
  includeScrollOffsets: false,

  // must be called before calling withinIncludingScrolloffset, every time the
  // page is scrolled
  prepare: function() {
    this.deltaX =  window.pageXOffset
                || document.documentElement.scrollLeft
                || document.body.scrollLeft
                || 0;
    this.deltaY =  window.pageYOffset
                || document.documentElement.scrollTop
                || document.body.scrollTop
                || 0;
  },

  // caches x/y coordinate pair to use with overlap
  within: function(element, x, y) {
    if (this.includeScrollOffsets)
      return this.withinIncludingScrolloffsets(element, x, y);
    this.xcomp = x;
    this.ycomp = y;
    this.offset = Element.cumulativeOffset(element);

    return (y >= this.offset[1] &&
            y <  this.offset[1] + element.offsetHeight &&
            x >= this.offset[0] &&
            x <  this.offset[0] + element.offsetWidth);
  },

  withinIncludingScrolloffsets: function(element, x, y) {
    var offsetcache = Element.cumulativeScrollOffset(element);

    this.xcomp = x + offsetcache[0] - this.deltaX;
    this.ycomp = y + offsetcache[1] - this.deltaY;
    this.offset = Element.cumulativeOffset(element);

    return (this.ycomp >= this.offset[1] &&
            this.ycomp <  this.offset[1] + element.offsetHeight &&
            this.xcomp >= this.offset[0] &&
            this.xcomp <  this.offset[0] + element.offsetWidth);
  },

  // within must be called directly before
  overlap: function(mode, element) {
    if (!mode) return 0;
    if (mode == 'vertical')
      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
        element.offsetHeight;
    if (mode == 'horizontal')
      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
        element.offsetWidth;
  },

  // Deprecation layer -- use newer Element methods now (1.5.2).

  cumulativeOffset: Element.Methods.cumulativeOffset,

  positionedOffset: Element.Methods.positionedOffset,

  absolutize: function(element) {
    Position.prepare();
    return Element.absolutize(element);
  },

  relativize: function(element) {
    Position.prepare();
    return Element.relativize(element);
  },

  realOffset: Element.Methods.cumulativeScrollOffset,

  offsetParent: Element.Methods.getOffsetParent,

  page: Element.Methods.viewportOffset,

  clone: function(source, target, options) {
    options = options || { };
    return Element.clonePosition(target, source, options);
  }
};

/*--------------------------------------------------------------------------*/

if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
  function iter(name) {
    return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
  }

  instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
  function(element, className) {
    className = className.toString().strip();
    var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
    return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
  } : function(element, className) {
    className = className.toString().strip();
    var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
    if (!classNames && !className) return elements;

    var nodes = MVC.$E(element).getElementsByTagName('*');
    className = ' ' + className + ' ';

    for (var i = 0, child, cn; child = nodes[i]; i++) {
      if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
          (classNames && classNames.all(function(name) {
            return !name.toString().blank() && cn.include(' ' + name + ' ');
          }))))
        elements.push(Element.extend(child));
    }
    return elements;
  };

  return function(className, parentElement) {
    return MVC.$E(parentElement || document.body).getElementsByClassName(className);
  };
}(Element.Methods);

/*--------------------------------------------------------------------------*/

Element.ClassNames = Class.create();
Element.ClassNames.prototype = {
  initialize: function(element) {
    this.element = MVC.$E(element);
  },

  _each: function(iterator) {
    this.element.className.split(/\s+/).select(function(name) {
      return name.length > 0;
    })._each(iterator);
  },

  set: function(className) {
    this.element.className = className;
  },

  add: function(classNameToAdd) {
    if (this.include(classNameToAdd)) return;
    this.set($A(this).concat(classNameToAdd).join(' '));
  },

  remove: function(classNameToRemove) {
    if (!this.include(classNameToRemove)) return;
    this.set($A(this).without(classNameToRemove).join(' '));
  },

  toString: function() {
    return $A(this).join(' ');
  }
};

Object.extend(Element.ClassNames.prototype, Enumerable);

/*--------------------------------------------------------------------------*/

Element.addMethods();;
include.set_path('jmvc/plugins/core');
if(typeof Prototype=="undefined"){
include({path:"../lang/standard_helpers.js",shrink_variables:false},"../lang/inflector/inflector","../dom/event/standard","../io/ajax/ajax","../lang/class/setup");
}else{
MVC.Event=Event;
include({path:"../lang/prototype_helpers.js",shrink_variables:false},"../lang/inflector/inflector","../io/ajax/prototype_ajax","../lang/class/setup");
}
if(MVC.Console){
include("../io/ajax/debug");
}
include("../view/view","../controller/controller","../controller/delegator","../controller/view/controller_view");
include.plugins("dom/element","controller/scaffold","model/view_helper","view/helpers");
if(include.get_env()=="development"){
include("../view/fulljslint");
}
;
include.set_path('jmvc/plugins/lang');
MVC.Native={};
MVC.Native.extend=function(_1,_2){
if(!MVC[_1]){
MVC[_1]={};
}
var _3=MVC[_1];
for(var _4 in _2){
_3[_4]=_2[_4];
if(!MVC._no_conflict){
window[_1][_4]=_2[_4];
if(typeof _2[_4]=="function"){
var _5=_2[_4].argumentNames();
if(_5.length==0){
continue;
}
var _6=_5[0];
if(_6.match(_1.toLowerCase())||(_6=="func"&&_1=="Function")){
MVC.Native.set_prototype(_1,_4,_2[_4]);
}
}
}
}
};
MVC.Native.set_prototype=function(_7,_8,_9){
if(!_9){
_9=MVC[_7][_8];
}
window[_7].prototype[_8]=function(){
var _a=[this];
for(var i=0,_c=arguments.length;i<_c;i++){
_a.push(arguments[i]);
}
return _9.apply(this,_a);
};
};
MVC.Object={};
MVC.Object.extend=Object.extend;
MVC.Object.to_query_string=function(_d,_e){
if(typeof _d!="object"){
return _d;
}
return MVC.Object.to_query_string.worker(_d,_e).join("&");
};
MVC.Object.to_query_string.worker=function(_f,_10){
var _11=[];
for(var _12 in _f){
if(_f.hasOwnProperty(_12)){
var _13=_f[_12];
if(_13&&_13.constructor===Date){
_13=_13.getUTCFullYear()+"-"+MVC.Number.to_padded_string(_13.getUTCMonth()+1,2)+"-"+MVC.Number.to_padded_string(_13.getUTCDate(),2)+" "+MVC.Number.to_padded_string(_13.getUTCHours(),2)+":"+MVC.Number.to_padded_string(_13.getUTCMinutes(),2)+":"+MVC.Number.to_padded_string(_13.getUTCSeconds(),2);
}
if(typeof _13!="object"){
var _14=encodeURIComponent(_13.toString());
var _15=encodeURIComponent(_10?_10+"["+_12+"]":_12);
_11.push(_15+"="+_14);
}else{
_11=_11.concat(MVC.Object.to_query_string.worker(_13,_10?_10+"["+_12+"]":_12));
}
}
}
return _11;
};
MVC.String={};
MVC.Object.extend(MVC.String,{capitalize:function(_16){
return _16.capitalize();
},include:function(_17,_18){
return _17.include(_18);
},ends_with:function(_19,_1a){
return _19.endsWith(_1a);
},camelize:function(_1b){
var _1c=_1b.split(/_|-/);
for(var i=1;i<_1c.length;i++){
_1c[i]=_1c[i].capitalize();
}
return _1c.join("");
},classize:function(_1e){
var _1f=_1e.split(/_|-/);
for(var i=0;i<_1f.length;i++){
_1f[i]=MVC.String.capitalize(_1f[i]);
}
return _1f.join("");
},strip:function(_21){
return _21.strip();
}});
if(!MVC._no_conflict){
MVC.Object.extend(String.prototype,{ends_with:function(_22){
return this.endsWith(_22);
},classize:function(){
var _23=this.split(/_|-/);
for(var i=0;i<_23.length;i++){
_23[i]=_23[i].capitalize();
}
return _23.join("");
}});
}
MVC.Array={};
MVC.Array.from=Array.from;
MVC.Array.include=function(_25,_26){
return _25.include(_26);
};
MVC.Function={bind:function(_27){
var _28=MVC.Array.from(arguments);
_28.shift();
_28.shift();
var _29=_27,_2a=arguments[1];
return function(){
return _29.apply(_2a,_28.concat(MVC.Array.from(arguments)));
};
},params:function(_2b){
return _2b.argumentNames();
}};
MVC.Native.extend("Number",{to_padded_string:function(_2c,_2d,_2e){
var _2f=_2c.toString(_2e||10);
var ret="";
for(var i=0;i<_2d-_2f.length;i++){
ret=+"0";
}
return ret+_2f;
}});
if(!MVC._no_conflict){
Function.prototype.params=Function.prototype.argumentNames;
}
MVC.Browser=Prototype.Browser;
;
include.set_path('jmvc/plugins/lang/inflector');
MVC.Inflector={Inflections:{plural:[[/(quiz)$/i,"$1zes"],[/^(ox)$/i,"$1en"],[/([m|l])ouse$/i,"$1ice"],[/(matr|vert|ind)ix|ex$/i,"$1ices"],[/(x|ch|ss|sh)$/i,"$1es"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/(hive)$/i,"$1s"],[/(?:([^f])fe|([lr])f)$/i,"$1$2ves"],[/sis$/i,"ses"],[/([ti])um$/i,"$1a"],[/(buffal|tomat)o$/i,"$1oes"],[/(bu)s$/i,"$1ses"],[/(alias|status)$/i,"$1es"],[/(octop|vir)us$/i,"$1i"],[/(ax|test)is$/i,"$1es"],[/s$/i,"s"],[/$/,"s"]],singular:[[/(quiz)zes$/i,"$1"],[/(matr)ices$/i,"$1ix"],[/(vert|ind)ices$/i,"$1ex"],[/^(ox)en/i,"$1"],[/(alias|status)es$/i,"$1"],[/(octop|vir)i$/i,"$1us"],[/(cris|ax|test)es$/i,"$1is"],[/(shoe)s$/i,"$1"],[/(o)es$/i,"$1"],[/(bus)es$/i,"$1"],[/([m|l])ice$/i,"$1ouse"],[/(x|ch|ss|sh)es$/i,"$1"],[/(m)ovies$/i,"$1ovie"],[/(s)eries$/i,"$1eries"],[/([^aeiouy]|qu)ies$/i,"$1y"],[/([lr])ves$/i,"$1f"],[/(tive)s$/i,"$1"],[/(hive)s$/i,"$1"],[/([^f])ves$/i,"$1fe"],[/(^analy)ses$/i,"$1sis"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i,"$1$2sis"],[/([ti])a$/i,"$1um"],[/(n)ews$/i,"$1ews"],[/s$/i,""]],irregular:[["move","moves"],["sex","sexes"],["child","children"],["man","men"],["foreman","foremen"],["person","people"]],uncountable:["sheep","fish","series","species","money","rice","information","equipment"]},pluralize:function(_1){
for(var i=0;i<MVC.Inflector.Inflections.uncountable.length;i++){
var _3=MVC.Inflector.Inflections.uncountable[i];
if(_1.toLowerCase()==_3){
return _3;
}
}
for(var i=0;i<MVC.Inflector.Inflections.irregular.length;i++){
var _4=MVC.Inflector.Inflections.irregular[i][0];
var _5=MVC.Inflector.Inflections.irregular[i][1];
if((_1.toLowerCase()==_4)||(_1==_5)){
return _1.substring(0,1)+_5.substring(1);
}
}
for(var i=0;i<MVC.Inflector.Inflections.plural.length;i++){
var _6=MVC.Inflector.Inflections.plural[i][0];
var _7=MVC.Inflector.Inflections.plural[i][1];
if(_6.test(_1)){
return _1.replace(_6,_7);
}
}
},singularize:function(_8){
for(var i=0;i<MVC.Inflector.Inflections.uncountable.length;i++){
var _a=MVC.Inflector.Inflections.uncountable[i];
if(_8.toLowerCase()==_a){
return _a;
}
}
for(var i=0;i<MVC.Inflector.Inflections.irregular.length;i++){
var _b=MVC.Inflector.Inflections.irregular[i][0];
var _c=MVC.Inflector.Inflections.irregular[i][1];
if((_8.toLowerCase()==_b)||(_8.toLowerCase()==_c)){
return _8.substring(0,1)+_b.substring(1);
}
}
for(var i=0;i<MVC.Inflector.Inflections.singular.length;i++){
var _d=MVC.Inflector.Inflections.singular[i][0];
var _e=MVC.Inflector.Inflections.singular[i][1];
if(_d.test(_8)){
return _8.replace(_d,_e);
}
}
}};
MVC.Native.extend("String",{pluralize:function(_f,_10,_11){
if(typeof _10=="undefined"){
return MVC.Inflector.pluralize(_f);
}else{
return _10+" "+(1==parseInt(_10)?_f:_11||MVC.Inflector.pluralize(_f));
}
},singularize:function(_12,_13){
if(typeof _13=="undefined"){
return MVC.Inflector.singularize(_12);
}else{
return _13+" "+MVC.Inflector.singularize(_12);
}
},is_singular:function(_14){
if(MVC.String.singularize(_14)==null&&_14){
return true;
}
return false;
}});
;
include.set_path('jmvc/plugins/io/ajax');
(function(){
var _1=MVC.Ajax.factory;
MVC.Ajax=Ajax.Request;
MVC.Ajax.prototype.set_request_headers=MVC.Ajax.setRequestHeaders;
MVC.Ajax.factory=_1;
Ajax.getTransport=MVC.Ajax.factory;
})();
;
include.set_path('jmvc/plugins/lang/class');
(function(){
var _1=false,_2=/xyz/.test(function(){
xyz;
})?/\b_super\b/:/.*/;
MVC.Class=function(){
};
MVC.Class.extend=function(_3,_4,_5){
if(typeof _3!="string"){
_5=_4;
_4=_3;
_3=null;
}
if(!_5){
_5=_4;
_4=null;
}
var _6=this;
var _7=this.prototype;
_1=true;
var _8=new this();
_1=false;
for(var _9 in _5){
_8[_9]=typeof _5[_9]=="function"&&typeof _7[_9]=="function"&&_2.test(_5[_9])?(function(_a,fn){
return function(){
var _c=this._super;
this._super=_7[_a];
var _d=fn.apply(this,arguments);
this._super=_c;
return _d;
};
})(_9,_5[_9]):_5[_9];
}
function Class(){
if(!_1&&this.init){
this.init.apply(this,arguments);
}
};
Class.prototype=_8;
Class.prototype.Class=Class;
Class.constructor=Class;
for(var _9 in this){
if(this.hasOwnProperty(_9)&&_9!="prototype"){
Class[_9]=this[_9];
}
}
for(var _9 in _4){
Class[_9]=typeof _4[_9]=="function"&&typeof Class[_9]=="function"&&_2.test(_4[_9])?(function(_e,fn){
return function(){
var tmp=this._super;
this._super=_6[_e];
var ret=fn.apply(this,arguments);
this._super=tmp;
return ret;
};
})(_9,_4[_9]):_4[_9];
}
Class.extend=arguments.callee;
if(_3){
Class.className=_3;
}
if(Class.init){
Class.init(Class);
}
if(_6.extended){
_6.extended(Class);
}
return Class;
};
})();
if(!MVC._no_conflict&&typeof Class=="undefined"){
Class=MVC.Class;
}
;
include.set_path('jmvc/plugins/view');
MVC.View=function(_1){
this.set_options(_1);
if(_1.precompiled){
this.template={};
this.template.process=_1.precompiled;
MVC.View.update(this.name,this);
return;
}
if(_1.url||_1.absolute_url||_1.view_url){
this.name=this.name?this.name:_1.url||_1.absolute_url||"views/"+_1.view_url;
var _2=_1.absolute_url||(_1.url?MVC.root.join(_1.url+(_1.url.match(/\.ejs/)?"":".ejs")):MVC.root.join("views/"+_1.view_url+(_1.view_url.match(/\.ejs/)?"":".ejs")));
var _3=MVC.View.get(this.name,this.cache);
if(_3){
return _3;
}
if(_3==MVC.View.INVALID_PATH){
return null;
}
this.text=include.request(_2+(this.cache||window._rhino?"":"?"+Math.random()));
if(this.text==null){
if(window._rhino){
print("Exception: "+"There is no template at "+_2);
}
throw ({type:"JMVC",message:"There is no template at "+_2});
}
}else{
if(_1.hasOwnProperty("element")){
if(typeof _1.element=="string"){
var _4=_1.element;
_1.element=MVC.$E(_1.element);
if(_1.element==null){
throw _4+"does not exist!";
}
}
if(_1.element.value){
this.text=_1.element.value;
}else{
this.text=_1.element.innerHTML;
}
this.name=_1.element.id;
this.type="[";
}
}
var _3=new MVC.View.Compiler(this.text,this.type);
_3.compile(_1);
MVC.View.update(this.name,this);
this.template=_3;
};
MVC.View.prototype={render:function(_5,_6){
_5=_5||{};
var v=new MVC.View.Helpers(_5);
MVC.Object.extend(v,_6||{});
return this.template.process.call(_5,_5,v);
},out:function(){
return this.template.out;
},set_options:function(_8){
this.type=_8.type!=null?_8.type:MVC.View.type;
this.cache=_8.cache!=null?_8.cache:MVC.View.cache;
this.text=_8.text!=null?_8.text:null;
this.name=_8.name!=null?_8.name:null;
},update:function(_9,_a){
if(typeof _9=="string"){
_9=MVC.$E(_9);
}
if(_a==null){
_template=this;
return function(_b){
MVC.View.prototype.update.call(_template,_9,_b);
};
}
if(typeof _a=="string"){
params={};
params.url=_a;
_template=this;
params.onComplete=function(_c){
var _d=eval("("+_c.responseText+")");
MVC.View.prototype.update.call(_template,_9,_d);
};
if(!MVC.Ajax){
alert("You must include the Ajax plugin to use this feature");
}
new MVC.Ajax(params.url,params);
}else{
_9.innerHTML=this.render(_a);
}
}};
MVC.View.Scanner=function(_e,_f,_10){
this.left_delimiter=_f+"%";
this.right_delimiter="%"+_10;
this.double_left=_f+"%%";
this.double_right="%%"+_10;
this.left_equal=_f+"%=";
this.left_comment=_f+"%#";
if(_f=="["){
this.SplitRegexp=/(\[%%)|(%%\])|(\[%=)|(\[%#)|(\[%)|(%\]\n)|(%\])|(\n)/;
}else{
this.SplitRegexp=new RegExp("("+this.double_left+")|(%%"+this.double_right+")|("+this.left_equal+")|("+this.left_comment+")|("+this.left_delimiter+")|("+this.right_delimiter+"\n)|("+this.right_delimiter+")|(\n)");
}
this.source=_e;
this.stag=null;
this.lines=0;
};
MVC.View.Scanner.to_text=function(_11){
if(_11==null||_11===undefined){
return "";
}
if(_11 instanceof Date){
return _11.toDateString();
}
if(_11.toString){
return _11.toString();
}
return "";
};
MVC.View.Scanner.prototype={scan:function(_12){
scanline=this.scanline;
regex=this.SplitRegexp;
if(!this.source==""){
var _13=MVC.String.rsplit(this.source,/\n/);
for(var i=0;i<_13.length;i++){
var _15=_13[i];
this.scanline(_15,regex,_12);
}
}
},scanline:function(_16,_17,_18){
this.lines++;
var _19=MVC.String.rsplit(_16,_17);
for(var i=0;i<_19.length;i++){
var _1b=_19[i];
if(_1b!=null){
try{
_18(_1b,this);
}
catch(e){
throw {type:"MVC.View.Scanner",line:this.lines};
}
}
}
}};
MVC.View.Buffer=function(_1c,_1d){
this.line=new Array();
this.script="";
this.pre_cmd=_1c;
this.post_cmd=_1d;
for(var i=0;i<this.pre_cmd.length;i++){
this.push(_1c[i]);
}
};
MVC.View.Buffer.prototype={push:function(cmd){
this.line.push(cmd);
},cr:function(){
this.script=this.script+this.line.join("; ");
this.line=new Array();
this.script=this.script+"\n";
},close:function(){
if(this.line.length>0){
for(var i=0;i<this.post_cmd.length;i++){
this.push(pre_cmd[i]);
}
this.script=this.script+this.line.join("; ");
line=null;
}
}};
MVC.View.Compiler=function(_21,_22){
this.pre_cmd=["var ___ViewO = [];"];
this.post_cmd=new Array();
this.source=" ";
if(_21!=null){
if(typeof _21=="string"){
_21=_21.replace(/\r\n/g,"\n");
_21=_21.replace(/\r/g,"\n");
this.source=_21;
}else{
if(_21.innerHTML){
this.source=_21.innerHTML;
}
}
if(typeof this.source!="string"){
this.source="";
}
}
_22=_22||"<";
var _23=">";
switch(_22){
case "[":
_23="]";
break;
case "<":
break;
default:
throw _22+" is not a supported deliminator";
break;
}
this.scanner=new MVC.View.Scanner(this.source,_22,_23);
this.out="";
};
MVC.View.Compiler.prototype={compile:function(_24){
_24=_24||{};
this.out="";
var _25="___ViewO.push(";
var _26=_25;
var _27=new MVC.View.Buffer(this.pre_cmd,this.post_cmd);
var _28="";
var _29=function(_2a){
_2a=_2a.replace(/\\/g,"\\\\");
_2a=_2a.replace(/\n/g,"\\n");
_2a=_2a.replace(/"/g,"\\\"");
return _2a;
};
this.scanner.scan(function(_2b,_2c){
if(_2c.stag==null){
switch(_2b){
case "\n":
_28=_28+"\n";
_27.push(_25+"\""+_29(_28)+"\");");
_27.cr();
_28="";
break;
case _2c.left_delimiter:
case _2c.left_equal:
case _2c.left_comment:
_2c.stag=_2b;
if(_28.length>0){
_27.push(_25+"\""+_29(_28)+"\")");
}
_28="";
break;
case _2c.double_left:
_28=_28+_2c.left_delimiter;
break;
default:
_28=_28+_2b;
break;
}
}else{
switch(_2b){
case _2c.right_delimiter:
switch(_2c.stag){
case _2c.left_delimiter:
if(_28[_28.length-1]=="\n"){
_28=MVC.String.chop(_28);
_27.push(_28);
_27.cr();
}else{
_27.push(_28);
}
break;
case _2c.left_equal:
_27.push(_26+"(MVC.View.Scanner.to_text("+_28+")))");
break;
}
_2c.stag=null;
_28="";
break;
case _2c.double_right:
_28=_28+_2c.right_delimiter;
break;
default:
_28=_28+_2b;
break;
}
}
});
if(_28.length>0){
_27.push(_25+"\""+_29(_28)+"\")");
}
_27.close();
this.out=_27.script+";";
var _2d="this.process = function(_CONTEXT,_VIEW) { try { with(_VIEW) { with (_CONTEXT) {"+this.out+" return ___ViewO.join('');}}}catch(e){e.lineNumber=null;throw e;}};";
try{
eval(_2d);
}
catch(e){
if(typeof JSLINT!="undefined"){
JSLINT(this.out);
for(var i=0;i<JSLINT.errors.length;i++){
var _30=JSLINT.errors[i];
if(_30.reason!="Unnecessary semicolon."){
_30.line++;
var e=new Error();
e.lineNumber=_30.line;
e.message=_30.reason;
if(_24.url){
e.fileName=_24.url;
}
throw e;
}
}
}else{
throw e;
}
}
}};
MVC.View.config=function(_31){
MVC.View.cache=_31.cache!=null?_31.cache:MVC.View.cache;
MVC.View.type=_31.type!=null?_31.type:MVC.View.type;
var _32={};
MVC.View.templates_directory=_32;
MVC.View.get=function(_33,_34){
if(_34==false){
return null;
}
if(_32[_33]){
return _32[_33];
}
return null;
};
MVC.View.update=function(_35,_36){
if(_35==null){
return;
}
_32[_35]=_36;
};
MVC.View.INVALID_PATH=-1;
};
MVC.View.config({cache:include.get_env()=="production",type:"<"});
MVC.View.PreCompiledFunction=function(_37,_38,f){
new MVC.View({name:_38,precompiled:f});
};
MVC.View.Helpers=function(_3a){
this.data=_3a;
};
MVC.View.Helpers.prototype={partial:function(_3b,_3c){
if(!_3c){
_3c=this.data;
}
return new MVC.View(_3b).render(_3c);
},to_text:function(_3d,_3e){
if(_3d==null||_3d===undefined){
return _3e||"";
}
if(_3d instanceof Date){
return _3d.toDateString();
}
if(_3d.toString){
return _3d.toString().replace(/\n/g,"<br />").replace(/''/g,"'");
}
return "";
}};
include.view=function(_3f){
if(include.get_env()=="development"){
new MVC.View({url:new MVC.File("../"+_3f).join_current()});
}else{
if(include.get_env()=="compress"){
include({path:"../"+_3f,process:MVC.View.process_include,ignore:true});
new MVC.View({url:new MVC.File("../"+_3f).join_current()});
}else{
}
}
};
include.views=function(){
for(var i=0;i<arguments.length;i++){
include.view(arguments[i]+".ejs");
}
};
MVC.View.process_include=function(_41){
var _42=new MVC.View({text:_41.text});
return "MVC.View.PreCompiledFunction(\""+_41.original_path+"\", \""+_41.path+"\",function(_CONTEXT,_VIEW) { try { with(_VIEW) { with (_CONTEXT) {"+_42.out()+" return ___ViewO.join('');}}}catch(e){e.lineNumber=null;throw e;}})";
};
if(!MVC._no_conflict){
View=MVC.View;
}
MVC.Native.extend("String",{rsplit:function(_43,_44){
var _45=_44.exec(_43);
var _46=new Array();
while(_45!=null){
var _47=_45.index;
var _48=_44.lastIndex;
if((_47)!=0){
var _49=_43.substring(0,_47);
_46.push(_43.substring(0,_47));
_43=_43.slice(_47);
}
_46.push(_45[0]);
_43=_43.slice(_45[0].length);
_45=_44.exec(_43);
}
if(!_43==""){
_46.push(_43);
}
return _46;
},chop:function(_4a){
return _4a.substr(0,_4a.length-1);
}});
;
include.set_path('jmvc/plugins/controller');
MVC.Object.is_number=function(o){
return o&&(typeof o=="number"||(typeof o=="string"&&!isNaN(o)));
};
MVC.Controller=MVC.Class.extend({init:function(){
if(!this.className){
return;
}
this.singularName=MVC.String.singularize(this.className);
if(!MVC.Controller.controllers[this.className]){
MVC.Controller.controllers[this.className]=[];
}
MVC.Controller.controllers[this.className].push(this);
var _2,_3;
this.actions={};
for(var _4 in this.prototype){
_2=this.prototype[_4];
if(typeof _2=="function"&&_4!="Class"){
for(var a=0;a<MVC.Controller.actions.length;a++){
_3=MVC.Controller.actions[a];
if(_3.matches(_4)){
this.actions[_4]=new _3(_4,_2,this);
}
}
}
}
this.modelName=MVC.String.classize(MVC.String.is_singular(this.className)?this.className:MVC.String.singularize(this.className));
if(include.get_env()=="test"){
var _6=MVC.root.join("test/functional/"+this.className+"_controller_test.js");
include("../test/functional/"+this.className+"_controller_test.js");
var _7=include.check_exists(_6);
if(_7){
MVC.Console.log("Loading: \"test/functional/"+this.className+"_controller_test.js\"");
}else{
MVC.Console.log("Test Controller not found at \"test/functional/"+this.className+"_controller_test.js\"");
return;
}
}
this._path=include.get_path().match(/(.*?)controllers/)[1]+"controllers";
},event_closure:function(_8,_9){
return MVC.Function.bind(function(_a){
var _b=new MVC.Controller.Params({event:_a,element:_9,action:_8,controller:this});
return this.dispatch(_8,_b);
},this);
},subscribe_closure:function(_c){
return MVC.Function.bind(function(_d,_e){
var _f=_e||{};
_f.action=_c;
_f.controller=this;
_f.event_name=_d;
return this.dispatch(_c,new MVC.Controller.Params(_f));
},this);
},dispatch_closure:function(_10){
return MVC.Function.bind(function(_11){
_11=_11||{};
_11.action=_10;
_11.controller=this;
_11=_11.constructor==MVC.Controller.Params?_11:new MVC.Controller.Params(_11);
return this.dispatch(_10,_11);
},this);
},dispatch:function(_12,_13){
if(!_12){
_12="index";
}
if(typeof _12=="string"){
if(!(_12 in this.prototype)){
throw "No action named "+_12+" was found for "+this.Class.className+" controller.";
}
}else{
_12=_12.name;
}
var _14=this._get_instance(_12,_13);
return this._dispatch_action(_14,_12,_13);
},_get_instance:function(_15,_16){
return new this(_15,_16);
},_dispatch_action:function(_17,_18,_19){
_17.params=_19;
_17.action_name=_18;
return _17[_18](_19);
},controllers:{},actions:[],publish:function(_1a,_1b){
OpenAjax.hub.publish(_1a,_1b);
},get_controller_with_name_and_action:function(_1c,_1d){
var _1e=MVC.Controller.controllers[_1c];
for(var i=0;i<_1e.length;i++){
var _20=_1e[i];
if(_20.actions[_1d]){
return _20;
}
}
return null;
}},{continue_to:function(_21){
if(!_21){
_21=this.action_name+"ing";
}
if(typeof this[_21]!="function"){
throw "There is no action named "+_21+". ";
}
return MVC.Function.bind(function(){
this.action_name=_21;
this[_21].apply(this,arguments);
},this);
},delay:function(_22,_23,_24){
if(typeof this[_23]!="function"){
throw "There is no action named "+_23+". ";
}
return setTimeout(MVC.Function.bind(function(){
this.Class._dispatch_action(this,_23,_24);
},this),_22);
},publish:function(_25,_26){
this.Class.publish(_25,_26);
}});
MVC.Controller.Action=MVC.Class.extend({init:function(){
if(this.matches){
MVC.Controller.actions.push(this);
}
}},{init:function(_27,f,_29){
this.action=_27;
this.func=f;
this.controller=_29;
}});
MVC.Controller.SubscribeAction=MVC.Controller.Action.extend({match:new RegExp("(.*?)\\s?(subscribe)$"),matches:function(_2a){
return this.match.exec(_2a);
}},{init:function(_2b,f,_2d){
this._super(_2b,f,_2d);
this.message();
OpenAjax.hub.subscribe(this.message_name,this.controller.subscribe_closure(_2b));
},message:function(){
this.parts=this.action.match(this.Class.match);
this.message_name=this.parts[1];
}});
MVC.Controller.DelegateAction=MVC.Controller.Action.extend({match:new RegExp("(.*?)\\s?(change|click|contextmenu|dblclick|keydown|keyup|keypress|mousedown|mousemove|mouseout|mouseover|mouseup|reset|resize|scroll|select|submit|dblclick|focus|blur|load|unload)$"),matches:function(_2e){
return this.match.exec(_2e);
}},{init:function(_2f,f,_31){
this._super(_2f,f,_31);
this.css_and_event();
var _32=this.selector();
if(_32!=null){
new MVC.Delegator(_32,this.event_type,this.controller.dispatch_closure(_2f));
}
},css_and_event:function(){
this.parts=this.action.match(this.Class.match);
this.css=this.parts[1];
this.event_type=this.parts[2];
},main_controller:function(){
if(!this.css&&MVC.Array.include(["blur","focus"],this.event_type)){
MVC.Event.observe(window,this.event_type,this.controller.event_closure(this.event_type,window));
return;
}
return this.css;
},plural_selector:function(){
if(this.css=="#"||this.css.substring(0,2)=="# "){
var _33=this.css.substring(2,this.css.length);
return "#"+this.controller.className+(_33?" "+_33:"");
}else{
return "."+MVC.String.singularize(this.controller.className)+(this.css?" "+this.css:"");
}
},singular_selector:function(){
return "#"+this.controller.className+(this.css?" "+this.css:"");
},selector:function(){
if(MVC.Array.include(["load","unload","resize","scroll"],this.event_type)){
MVC.Event.observe(window,this.event_type,this.controller.event_closure(this.event_type,window));
return;
}
if(this.controller.className=="main"){
this.css_selector=this.main_controller();
}else{
this.css_selector=MVC.String.is_singular(this.controller.className)?this.singular_selector():this.plural_selector();
}
return this.css_selector;
}});
MVC.Controller.Params=function(_34){
var _34=_34||{};
var _35=false;
this.kill=function(){
_35=true;
if(_34.event.kill){
_34.event.kill();
}
};
this.is_killed=function(){
return _34.event.is_killed?_34.event.is_killed():_35;
};
for(var _36 in _34){
if(_34.hasOwnProperty(_36)){
this[_36]=_34[_36];
}
}
this.constructor=MVC.Controller.Params;
};
MVC.Controller.Params.prototype={form_params:function(){
var _37={};
if(this.element.nodeName.toLowerCase()!="form"){
return _37;
}
var els=this.element.elements,_39=[];
for(var i=0;i<els.length;i++){
var el=els[i];
if(el.type.toLowerCase()=="submit"){
continue;
}
var key=el.name||el.id,_3d=key.match(/(\w+)/g),_3e;
if(!key){
continue;
}
switch(el.type.toLowerCase()){
case "checkbox":
case "radio":
_3e=!!el.checked;
break;
default:
_3e=el.value;
break;
}
if(_3d.length>1){
var _3f=_3d.length-1;
var _40=_3d[0].toString();
if(!_37[_40]){
_37[_40]={};
}
var _41=_37[_40];
for(var k=1;k<_3f;k++){
_40=_3d[k];
if(!_41[_40]){
_41[_40]={};
}
_41=_41[_40];
}
_41[_3d[_3f]]=_3e;
}else{
if(key in _37){
if(typeof _37[key]=="string"){
_37[key]=[_37[key]];
}
_37[key].push(_3e);
}else{
_37[key]=_3e;
}
}
}
return _37;
},class_element:function(){
var _43=this.element;
var _44=this._className();
while(_43&&_43.className.indexOf(_44)==-1){
_43=_43.parentNode;
if(_43==document){
return null;
}
}
return _43;
},is_event_on_element:function(){
return this.event.target==this.element;
},_className:function(){
return this.controller.singularName;
},element_instance:function(){
var _45,_46,_47=this._className();
if(!(_45=MVC.Model.models[_47])){
throw "No model for the "+_47+" controller!";
}
_46=new RegExp("^"+_47+"_(.*)$");
var id=this.class_element().id.match(_46)[1];
return _45.store.find_one(id);
}};
if(!MVC._no_conflict&&typeof Controller=="undefined"){
Controller=MVC.Controller;
}
;
include.set_path('jmvc/plugins/controller');
MVC.Delegator=function(_1,_2,f){
this._event=_2;
this._selector=_1;
this._func=f;
if(_2=="contextmenu"&&MVC.Browser.Opera){
return this.context_for_opera();
}
if(_2=="submit"&&MVC.Browser.IE){
return this.submit_for_ie();
}
if(_2=="change"&&MVC.Browser.IE){
return this.change_for_ie();
}
if(_2=="change"&&MVC.Browser.WebKit){
return this.change_for_webkit();
}
this.add_to_delegator();
};
MVC.Object.extend(MVC.Delegator,{node_path:function(el){
var _5=document.documentElement,_6=[],_7=el;
while(_7!=_5){
_6.unshift({tag:_7.nodeName,className:_7.className,id:_7.id,element:_7});
_7=_7.parentNode;
if(_7==null){
return [];
}
}
return _6;
},dispatch_event:function(_8){
var _9=_8.target,_a=false,_b=true,_c=[];
var _d=MVC.Delegator.events[_8.type];
var _e=MVC.Delegator.node_path(_9);
for(var i=0;i<_d.length;i++){
var _10=_d[i];
var _11=_10.match(_9,_8,_e);
if(_11){
_c.push(_11);
}
}
if(_c.length==0){
return true;
}
MVC.Delegator.add_kill_event(_8);
_c.sort(MVC.Delegator.sort_by_order);
var _12;
for(var m=0;m<_c.length;m++){
_12=_c[m];
_b=_12.delegation_event._func({event:_8,element:_12.node})&&_b;
if(_8.is_killed()){
return false;
}
}
},add_kill_event:function(_14){
if(!_14.kill){
var _15=false;
_14.kill=function(){
_15=true;
if(!_14){
_14=window.event;
}
try{
_14.cancelBubble=true;
if(_14.stopPropagation){
_14.stopPropagation();
}
if(_14.preventDefault){
_14.preventDefault();
}
}
catch(e){
}
};
_14.is_killed=function(){
return _15;
};
}
},sort_by_order:function(a,b){
if(a.order<b.order){
return 1;
}
if(b.order<a.order){
return -1;
}
var ae=a._event,be=b._event;
if(ae=="click"&&be=="change"){
return 1;
}
if(be=="click"&&ae=="change"){
return -1;
}
return 0;
},events:{}});
MVC.Delegator.prototype={event:function(){
if(MVC.Browser.IE){
if(this._event=="focus"){
return "activate";
}else{
if(this._event=="blur"){
return "deactivate";
}
}
}
return this._event;
},capture:function(){
return MVC.Array.include(["focus","blur"],this._event);
},add_to_delegator:function(_1a,_1b,_1c){
var s=_1a||this._selector;
var e=_1b||this.event();
var f=_1c||this._func;
if(!MVC.Delegator.events[e]){
MVC.Event.observe(document.documentElement,e,MVC.Delegator.dispatch_event,this.capture());
MVC.Delegator.events[e]=[];
}
MVC.Delegator.events[e].push(this);
},submit_for_ie:function(){
this.add_to_delegator(null,"click");
this.add_to_delegator(null,"keypress");
this.filters={click:function(el,_21,_22){
if(el.nodeName.toUpperCase()=="INPUT"&&el.type.toLowerCase()=="submit"){
for(var e=0;e<_22.length;e++){
if(_22[e].tag=="FORM"){
return true;
}
}
}
return false;
},keypress:function(el,_25,_26){
if(el.nodeName.toUpperCase()!="INPUT"){
return false;
}
var res=typeof Prototype!="undefined"?(_25.keyCode==13):(_25.charCode==13);
if(res){
for(var e=0;e<_26.length;e++){
if(_26[e].tag=="FORM"){
return true;
}
}
}
return false;
}};
},change_for_ie:function(){
this.add_to_delegator(null,"click");
this.end_filters={click:function(el,_2a){
if(typeof el.selectedIndex=="undefined"||el.nodeName.toUpperCase()!="SELECT"){
return false;
}
var old=el.getAttribute("_old_value");
if(old==null){
el.setAttribute("_old_value",el.selectedIndex);
return false;
}else{
if(old==el.selectedIndex.toString()){
return false;
}
el.setAttribute("_old_value",null);
return true;
}
}};
},change_for_webkit:function(){
this.add_to_delegator(null,"change");
this.end_filters={change:function(el,_2d){
if(typeof el.value=="undefined"){
return false;
}
var old=el.getAttribute("_old_value");
el.setAttribute("_old_value",el.value);
return el.value!=old;
}};
},context_for_opera:function(){
this.add_to_delegator(null,"click");
this.end_filters={click:function(el,_30){
return _30.shiftKey;
}};
},regexp_patterns:{tag:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/},selector_order:function(){
if(this.order){
return this.order;
}
var _31=this._selector.split(/\s+/);
var _32=this.regexp_patterns;
var _33=[];
for(var i=0;i<_31.length;i++){
var v={},r,p=_31[i];
for(var _38 in _32){
if(_32.hasOwnProperty(_38)){
if((r=p.match(_32[_38]))){
if(_38=="tag"){
v[_38]=r[1].toUpperCase();
}else{
v[_38]=r[1];
}
p=p.replace(r[0],"");
}
}
}
_33.push(v);
}
this.order=_33;
return this.order;
},match:function(el,_3a,_3b){
if(this.filters&&!this.filters[_3a.type](el,_3a,_3b)){
return null;
}
var _3c=0;
for(var n=0;n<_3b.length;n++){
var _3e=_3b[n],_3f=this.selector_order()[_3c],_40=true;
for(var _41 in _3f){
if(!_3f.hasOwnProperty(_41)||_41=="element"){
continue;
}
if(_3f[_41]&&_41=="className"){
if(!MVC.Array.include(_3e.className.split(" "),_3f[_41])){
_40=false;
}
}else{
if(_3f[_41]&&_3e[_41]!=_3f[_41]){
_40=false;
}
}
}
if(_40){
_3c++;
if(_3c>=this.selector_order().length){
if(this.end_filters&&!this.end_filters[_3a.type](el,_3a)){
return null;
}
return {node:_3e.element,order:n,delegation_event:this};
}
}
}
return null;
}};
;
include.set_path('jmvc/plugins/controller/view');
MVC.Controller.prototype.render=function(_1){
var _2,_3=MVC.RENDER_TO,_4;
var _5=this.Class.className;
var _6=this.action_name;
if(!_1){
_1={};
}
var _7={};
if(_1.helpers){
for(var h=0;h<_1.helpers.length;h++){
var n=MVC.String.classize(_1.helpers[h]);
MVC.Object.extend(_7,window[n]?window[n].View().helpers:{});
}
}
if(typeof _1=="string"){
_2=new MVC.View({url:_1}).render(this,_7);
}else{
if(_1.text){
_2=_1.text;
}else{
var _a=function(_b){
var _b=MVC.String.include(_b,"/")?_b.split("/").join("/_"):_5+"/"+_b;
var _b=_b+".ejs";
return _b;
};
if(_1.plugin){
_4="../jmvc/plugins/"+_1.plugin;
}
if(_1.action){
var _c="../views/"+_a(_1.action);
}else{
if(_1.partial){
var _c="../views/"+_a(_1.partial);
}else{
var _c="../views/"+_5+"/"+_6.replace(/\.|#/g,"").replace(/ /g,"_")+".ejs";
}
}
var _d=this;
if(_1.locals){
for(var _e in _1.locals){
_d[_e]=_1.locals[_e];
}
}
var _f;
if(!_4){
_f=new MVC.View({url:new MVC.File(_c).join_from(this.Class._path)});
}else{
try{
var _f=new MVC.View({url:MVC.View.get(_4)?_4:_c});
}
catch(e){
if(e.type!="JMVC"){
throw e;
}
var _f=new MVC.View({url:_4});
}
}
_2=_f.render(_d,_7);
}
}
var _10=["to","before","after","top","bottom"];
var _11=null;
for(var l=0;l<_10.length;l++){
if(typeof _1[_10[l]]=="string"){
var id=_1[_10[l]];
_1[_10[l]]=MVC.$E(id);
if(!_1[_10[l]]){
throw {message:"Can't find element with id: "+id,name:"ControllerView: Missing Element"};
}
}
if(_1[_10[l]]){
_11=_1[_10[l]];
if(_10[l]=="to"){
if(MVC.$E.update){
MVC.$E.update(_1.to,_2);
}else{
_1.to.innerHTML=_2;
}
}else{
if(!MVC.$E.insert){
throw {message:"Include can't insert "+_10[l]+" without the element plugin.",name:"ControllerView: Missing Plugin"};
}
var opt={};
opt[_10[l]]=_2;
MVC.$E.insert(_11,opt);
}
}
}
return _2;
};
;
include.set_path('jmvc/plugins/dom/element');
include.plugins("lang/vector");
include("element");
;
include.set_path('jmvc/plugins/lang/vector');
include.plugins("lang","dom/event");
include("vector");
;
include.set_path('jmvc/plugins/lang');
if(typeof Prototype!="undefined"){
include({path:"prototype_helpers.js",shrink_variables:false});
}else{
if(typeof jQuery!="undefined"){
include({path:"jquery_helpers.js",shrink_variables:false});
}else{
include({path:"standard_helpers.js",shrink_variables:false});
}
}
;
include.set_path('jmvc/plugins/dom/event');
if(typeof Prototype=="undefined"){
include("standard");
}else{
include("prototype_event");
}
;
include.set_path('jmvc/plugins/dom/event');
MVC.Event={};
MVC.Event.stop_observing=Event.stopObserving;
MVC.Event.observe=function(_1,_2,_3,_4){
var _5=Event.cache;
function getEventID(_6){
if(_6._eventID){
return _6._eventID;
}
arguments.callee.id=arguments.callee.id||1;
return _6._eventID=++arguments.callee.id;
};
function getDOMEventName(_7){
if(_7&&_7.include(":")){
return "dataavailable";
}
return _7;
};
function getCacheForID(id){
return _5[id]=_5[id]||{};
};
function getWrappersForEventName(id,_a){
var c=getCacheForID(id);
return c[_a]=c[_a]||[];
};
function createWrapper(_c,_d,_e){
var id=getEventID(_c);
var c=getWrappersForEventName(id,_d);
if(c.pluck("handler").include(_e)){
return false;
}
var _11=function(_12){
if(!Event||!Event.extend||(_12.eventName&&_12.eventName!=_d)){
return false;
}
Event.extend(_12);
_e.call(_c,_12);
};
_11.handler=_e;
c.push(_11);
return _11;
};
function findWrapper(id,_14,_15){
var c=getWrappersForEventName(id,_14);
return c.find(function(_17){
return _17.handler==_15;
});
};
function destroyWrapper(id,_19,_1a){
var c=getCacheForID(id);
if(!c[_19]){
return false;
}
c[_19]=c[_19].without(findWrapper(id,_19,_1a));
};
function destroyCache(){
for(var id in _5){
for(var _1d in _5[id]){
_5[id][_1d]=null;
}
}
};
_1=MVC.$E(_1);
var _1e=getDOMEventName(_2);
var _1f=createWrapper(_1,_2,_3);
if(!_1f){
return _1;
}
if(_1.addEventListener){
_1.addEventListener(_1e,_1f,_4);
}else{
_1.attachEvent("on"+_1e,_1f);
}
return _1;
};
;
include.set_path('jmvc/plugins/lang/vector');
MVC.Vector=function(){
this.update(MVC.Array.from(arguments));
};
MVC.Vector.prototype={app:function(f){
var _2=[];
for(var i=0;i<this.array.length;i++){
_2.push(f(this.array[i]));
}
var _4=new MVC.Vector();
return _4.update(_2);
},plus:function(){
var _5=arguments[0] instanceof MVC.Vector?arguments[0].array:MVC.Array.from(arguments),_6=this.array.slice(0),_7=new MVC.Vector();
for(var i=0;i<_5.length;i++){
_6[i]=(_6[i]?_6[i]:0)+_5[i];
}
return _7.update(_6);
},minus:function(){
var _9=arguments[0] instanceof MVC.Vector?arguments[0].array:MVC.Array.from(arguments),_a=this.array.slice(0),_b=new MVC.Vector();
for(var i=0;i<_9.length;i++){
_a[i]=(_a[i]?_a[i]:0)-_9[i];
}
return _b.update(_a);
},x:function(){
return this.array[0];
},y:function(){
return this.array[1];
},top:function(){
return this.array[1];
},left:function(){
return this.array[0];
},toString:function(){
return "("+this.array[0]+","+this.array[1]+")";
},update:function(_d){
if(this.array){
for(var i=0;i<this.array.length;i++){
delete this.array[i];
}
}
this.array=_d;
for(var i=0;i<_d.length;i++){
this[i]=this.array[i];
}
return this;
}};
MVC.Event.pointer=function(_f){
return new MVC.Vector(_f.pageX||(_f.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)),_f.pageY||(_f.clientY+(document.documentElement.scrollTop||document.body.scrollTop)));
};
;
include.set_path('jmvc/plugins/dom/element');
MVC.Element=function(_1){
if(typeof _1=="string"){
_1=document.getElementById(_1);
}
if(!_1){
return _1;
}
return _1._mvcextend?_1:MVC.Element.extend(_1);
};
MVC.Object.extend(MVC.Element,{insert:function(_2,_3){
_2=MVC.$E(_2);
if(typeof _3=="string"){
_3={bottom:_3};
}
var _4,_5,_6,_7;
for(position in _3){
if(!_3.hasOwnProperty(position)){
continue;
}
_4=_3[position];
position=position.toLowerCase();
_5=MVC.$E._insertionTranslations[position];
if(_4&&_4.nodeType==1){
_5(_2,_4);
continue;
}
_6=((position=="before"||position=="after")?_2.parentNode:_2).tagName.toUpperCase();
_7=MVC.$E._getContentFromAnonymousElement(_6,_4);
if(position=="top"||position=="after"){
_7.reverse();
}
for(var c=0;c<_7.length;c++){
_5(_2,_7[c]);
}
}
return _2;
},_insertionTranslations:{before:function(_9,_a){
_9.parentNode.insertBefore(_a,_9);
},top:function(_b,_c){
_b.insertBefore(_c,_b.firstChild);
},bottom:function(_d,_e){
_d.appendChild(_e);
},after:function(_f,_10){
_f.parentNode.insertBefore(_10,_f.nextSibling);
},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}},_getContentFromAnonymousElement:function(_11,_12){
var div=document.createElement("div"),t=MVC.$E._insertionTranslations.tags[_11];
if(t){
div.innerHTML=t[0]+_12+t[1];
for(var i=0;i<t[2];i++){
div=div.firstChild;
}
}else{
div.innerHTML=_12;
}
return MVC.Array.from(div.childNodes);
},get_children:function(_16){
var els=[];
var el=_16.first();
while(el){
els.push(el);
el=el.next();
}
return els;
},first:function(_19,_1a){
_1a=_1a||function(){
return true;
};
var _1b=_19.firstChild;
while(_1b&&_1b.nodeType!=1||(_1b&&!_1a(_1b))){
_1b=_1b.nextSibling;
}
return MVC.$E(_1b);
},last:function(_1c,_1d){
_1d=_1d||function(){
return true;
};
var _1e=_1c.lastChild;
while(_1e&&_1e.nodeType!=1||(_1e&&!_1d(_1e))){
_1e=_1e.previousSibling;
}
return MVC.$E(_1e);
},next:function(_1f,_20,_21){
_21=_21||function(){
return true;
};
var _22=_1f.nextSibling;
while(_22&&_22.nodeType!=1||(_22&&!_21(_22))){
_22=_22.nextSibling;
}
if(!_22&&_20){
return MVC.$E(_1f.parentNode).first(_21);
}
return MVC.$E(_22);
},previous:function(_23,_24,_25){
_25=_25||function(){
return true;
};
var _26=_23.previousSibling;
while(_26&&_26.nodeType!=1||(_26&&!_25(_26))){
_26=_26.previousSibling;
}
if(!_26&&_24){
return MVC.$E(_23.parentNode).last(_25);
}
return MVC.$E(_26);
},toggle:function(_27){
return _27.style.display=="none"?_27.style.display="":_27.style.display="none";
},make_positioned:function(_28){
_28=MVC.$E(_28);
var pos=MVC.Element.get_style(_28,"position");
if(pos=="static"||!pos){
_28._madePositioned=true;
_28.style.position="relative";
if(window.opera){
_28.style.top=0;
_28.style.left=0;
}
}
return _28;
},get_style:function(_2a,_2b){
_2a=MVC.$E(_2a);
_2b=_2b=="float"?"cssFloat":MVC.String.camelize(_2b);
var _2c;
if(_2a.currentStyle){
var _2c=_2a.currentStyle[_2b];
}else{
var css=document.defaultView.getComputedStyle(_2a,null);
_2c=css?css[_2b]:null;
}
if(_2b=="opacity"){
return _2c?parseFloat(_2c):1;
}
return _2c=="auto"?null:_2c;
},cumulative_offset:function(_2e){
var _2f=0,_30=0;
do{
_2f+=_2e.offsetTop||0;
_30+=_2e.offsetLeft||0;
_2e=_2e.offsetParent;
}while(_2e);
return new MVC.Vector(_30,_2f);
},cumulative_scroll_offset:function(_31){
var _32=0,_33=0;
do{
_32+=_31.scrollTop||0;
_33+=_31.scrollLeft||0;
_31=_31.parentNode;
}while(_31);
return new MVC.Vector(_33,_32);
},is_parent:function(_34,_35){
if(typeof _35=="string"){
_35=MVC.$E(_35);
}
if(!_35.parentNode||_35==_34){
return false;
}
if(_35.parentNode==_34){
return true;
}
return MVC.Element.is_parent(_35.parentNode,_34);
},has:function(_36,b){
if(typeof b=="string"){
b=MVC.$E(b);
}
return _36.contains?_36!=b&&_36.contains(b):!!(_36.compareDocumentPosition(b)&16);
},update:function(_38,_39){
_38=MVC.$E(_38);
var _3a=_38.tagName.toUpperCase();
if((!MVC.Browser.IE&&!MVC.Browser.Opera)||!(_3a in MVC.$E._insertionTranslations.tags)){
_38.innerHTML=_39;
}else{
var _3b;
while((_3b=_38.childNodes[0])){
_38.removeChild(_3b);
}
var _3c=MVC.$E._getContentFromAnonymousElement(_3a,_39);
for(var c=0;c<_3c.length;c++){
_38.appendChild(_3c[c]);
}
}
return _38;
},remove:function(_3e){
return _3e.parentNode.removeChild(_3e);
},dimensions:function(_3f){
var _40=_3f.style.display;
if(_40!="none"&&_40!=null){
return new MVC.Vector(_3f.offsetWidth,_3f.offsetHeight);
}
var els=_3f.style;
var _42=els.visibility;
var _43=els.position;
var _44=els.display;
els.visibility="hidden";
els.position="absolute";
els.display="block";
var _45=_3f.clientWidth;
var _46=_3f.clientHeight;
els.display=_44;
els.position=_43;
els.visibility=_42;
return new MVC.Vector(_45,_46);
},add_class:function(_47,_48){
var cns=_47.className.split(/\s+/);
if(MVC.Array.include(cns,_48)){
return;
}
cns.push(_48);
_47.className=cns.join(" ");
},remove_class:function(_4a,_4b){
var cns=_4a.className.split(/\s+/);
var _4d=[];
for(var i=0;i<cns.length;i++){
if(cns[i]!=_4b){
_4d.push(cns[i]);
}
}
_4a.className=_4d.join(" ");
}});
MVC.Element.extend=function(el){
for(var f in MVC.Element){
if(!MVC.Element.hasOwnProperty(f)){
continue;
}
var _51=MVC.Element[f];
if(typeof _51=="function"){
if(f[0]!="_"){
MVC.Element._extend(_51,f,el);
}
}
}
el._mvcextend=true;
return el;
};
MVC.Element._extend=function(f,_53,el){
el[_53]=function(){
var arg=MVC.Array.from(arguments);
arg.unshift(el);
return f.apply(el,arg);
};
};
MVC.$E=MVC.Element;
if(!MVC._no_conflict){
$E=MVC.$E;
}
;
include.set_path('jmvc/plugins/controller/scaffold');
MVC.Controller.scaffold=function(){
if(!this.className){
return;
}
var _1=MVC.String.singularize(MVC.String.classize(this.className));
this.scaffold_model=window[_1];
this.singular_name=MVC.String.singularize(this.className);
for(var _2 in MVC.Controller.scaffold.functions){
if(this.prototype[_2]){
continue;
}
this.prototype[_2]=MVC.Controller.scaffold.functions[_2];
}
if(!window[_1+"ViewHelper"]){
this.scaffold_view_helper=window[_1+"ViewHelper"]=MVC.ModelViewHelper.extend(this.singular_name);
}else{
this.scaffold_view_helper=window[_1+"ViewHelper"];
}
};
MVC.Controller.scaffold.functions={load:function(_3){
if(!MVC.$E(this.Class.className)){
var _4=document.createElement("div");
_4.id=this.Class.className;
document.body.appendChild(_4);
}
this.Class.scaffold_model.find("all",{},this.continue_to("list"));
},list:function(_5){
this.singular_name=this.Class.singular_name;
this[this.Class.className]=_5;
this.controller_name=this.Class.className;
this.objects=_5;
this.render({to:this.Class.className,plugin:"controller/scaffold/display",action:this.Class.className});
},"# form submit":function(_6){
_6.event.kill();
this.Class.scaffold_model.create(_6.form_params()[this.Class.singular_name],this.continue_to("created"));
},created:function(_7){
if(_7.errors.length>0){
_7.View().show_errors();
}else{
this.Class.scaffold_model.View().clear();
_7.View().clear_errors();
this[this.Class.className]=[_7];
this.objects=[_7];
this.singular_name=this.Class.singular_name;
this.render({bottom:"recipe_list",plugin:"controller/scaffold/list",action:"list"});
}
},".delete click":function(_8){
this[this.Class.singular_name]=_8.object_data();
if(confirm("Are you sure you want to delete")){
this[this.Class.singular_name].destroy(this.continue_to("destroyed"));
}
},".edit click":function(_9){
this[this.Class.singular_name]=_9.object_data();
this.singular_name=this.Class.singular_name;
this.render({to:this[this.Class.singular_name].View().element_id(),action:"edit",plugin:"controller/scaffold/edit"});
},".cancel click":function(_a){
this.show(_a.object_data());
},".save click":function(_b){
this[this.Class.singular_name]=_b.object_data();
var _c=this[this.Class.singular_name].View().edit_values();
this[this.Class.singular_name].update_attributes(_c,this.continue_to("show"));
},show:function(_d){
this[this.Class.singular_name]=_d;
this.singular_name=this.Class.singular_name;
this.render({to:this[this.Class.singular_name].View().element_id(),action:"show",plugin:"controller/scaffold/show"});
},destroyed:function(_e){
if(_e){
this[this.Class.singular_name].View().destroy();
}
}};
;
include.set_path('jmvc/plugins/model/view_helper');
include("model_view_helper");
;
include.set_path('jmvc/plugins/model/view_helper');
MVC.ModelViewHelper=MVC.Class.extend({init:function(){
if(!this.className){
return;
}
var _1;
if(!this.className){
return;
}
if(!(_1=this.modelClass=window[MVC.String.classize(this.className)])){
throw "ModelViewHelpers can't find class "+this.className;
}
var _2=this;
this.modelClass.View=function(){
return _2;
};
this.modelClass.prototype.View=function(){
return new _2(this);
};
if(this.modelClass.attributes){
this._view=new MVC.View.Helpers({});
var _3;
for(var _4 in this.modelClass.attributes){
if(!this.modelClass.attributes.hasOwnProperty(_4)||typeof this.modelClass.attributes[_4]!="string"){
continue;
}
this.add_helper(_4);
}
}
},form_helper:function(_5){
if(!this.helpers[_5]+"_field"){
this.add_helper(_5);
}
var f=this.helpers[_5+"_field"];
var _7=MVC.Array.from(arguments);
_7.shift();
return f.apply(this._view,_7);
},add_helper:function(_8){
var h=this._helper(_8);
this.helpers[_8+"_field"]=h;
},helpers:{},_helper:function(_a){
var _b=this._view_helper(_a);
var _c=this;
var _d=this.modelClass.className+"["+_a+"]";
var id=this.modelClass.className+"_"+_a;
return function(){
var _f=MVC.Array.from(arguments);
_f.unshift(_d);
_f[2]=_f[2]||{};
_f[2].id=id;
return _b.apply(_c._view,_f);
};
},_view_helper:function(_10){
switch(this.modelClass.attributes[_10].toLowerCase()){
case "boolean":
return this._view.check_box_tag;
case "text":
return this._view.text_area_tag;
default:
return this._view.text_field_tag;
}
},clear:function(){
var _11=this.modelClass.className,el;
for(var _13 in this.modelClass.attributes){
if((el=MVC.$E(_11+"_"+_13))){
el.value="";
}
}
},from_html:function(_14){
var el=MVC.$E(_14);
var _16=this.modelClass?this.modelClass:window[MVC.String.classize(el.getAttribute("type"))];
if(!_16){
return null;
}
var _17={};
_17[_16.id]=this.element_id_to_id(el.id);
return _16.create_as_existing(_17);
},element_id_to_id:function(_18){
var re=new RegExp(this.className+"_","");
return _18.replace(re,"");
}},{init:function(_1a){
this._inst=_1a;
this._className=this._inst.Class.className;
this._Class=this._inst.Class;
},id:function(){
return this._inst[this._inst.Class.id];
},element:function(){
if(this._element){
return this._element;
}
this._element=MVC.$E(this.element_id());
if(this._element){
return this._element;
}
},create_element:function(){
this._element=document.createElement("div");
this._element.id=this.element_id();
this._element.className=this._className;
this._element.setAttribute("type",this._className);
return this._element;
},element_id:function(){
return this._className+"_"+this._inst[this._inst.Class.id];
},show_errors:function(){
var err=MVC.$E(this._className+"_error");
var err=err||MVC.$E(this._className+"_error");
var _1c=[];
for(var i=0;i<this._inst.errors.length;i++){
var _1e=this._inst.errors[i];
var el=MVC.$E(this._className+"_"+_1e[0]);
if(el){
el.className="error";
var _20=MVC.$E(this._className+"_"+_1e[0]+"_error");
if(_20){
_20.innerHTML=_1e[1];
}
}else{
_1c.push(_1e[0]+" is "+_1e[1]);
}
}
if(_1c.length>0){
if(err){
err.innerHTML=_1c.join(", ");
}else{
alert(_1c.join(", "));
}
}
},clear_errors:function(){
var p;
var cn=this._className;
for(var _23 in this._Class.attributes){
if(this._Class.attributes.hasOwnProperty(_23)){
var el=MVC.$E(cn+"_"+p);
if(el){
el.className=el.className.replace(/(^|\\s+)error(\\s+|$)/," ");
}
var _25=MVC.$E(cn+"_"+_23+"_error");
if(_25){
_25.innerHTML="&nbsp;";
}
}
}
var _26=MVC.$E(cn+"_error");
if(_26){
_26.innerHTML="";
}
},edit:function(_27){
var _28=MVC.Array.from(arguments);
var _29=this._className+"["+_27+"]";
_28.shift();
_28.unshift({id:this.edit_id(_27)});
_28.unshift(this._inst[_27]);
_28.unshift(_29);
var _2a=this.Class._view_helper(_27);
return _2a.apply(this.Class._view,_28);
},edit_values:function(){
var _2b={};
var cn=this._className,p,el;
for(var _2f in this._Class.attributes){
if(this._Class.attributes.hasOwnProperty(_2f)){
el=MVC.$E(this.edit_id(_2f));
}
if(el){
_2b[_2f]=el.value;
}
}
return _2b;
},edit_id:function(_30){
return this._className+"_"+this._inst.id+"_"+_30+"_edit";
},destroy:function(){
var el=this.element();
el.parentNode.removeChild(el);
}});
MVC.Controller.Params.prototype.object_data=function(){
var _32=this._className(),_33,_34=this.element,_35=new RegExp("^"+_32+"_(.*)$");
if(!(_33=MVC.Model.models[_32])){
return;
}
while(_34&&_34.parentNode&&!_34.id.match(_35)){
_34=_34.parentNode;
}
if(!_34){
return null;
}
var id=_34.id.match(_35)[1];
return _33.store.find_one(id);
};
;
include.set_path('jmvc/plugins/view/helpers');
include.plugins("view");
include("view_helpers");
;
include.set_path('jmvc/plugins/view');
include.plugins("lang");
include("view");
if(include.get_env()=="development"){
include("fulljslint");
}
if(MVC.Controller){
include.plugins("controller/view");
}
;
include.set_path('jmvc/plugins/controller/view');
include.plugins("view","controller");
include("controller_view");
;
include.set_path('jmvc/plugins/controller');
include.plugins("lang","lang/inflector","dom/event","lang/class","lang/openajax");
include("delegator","controller");
if(MVC.View){
include.plugins("controller/view");
}
;
include.set_path('jmvc/plugins/lang/inflector');
include.plugins("lang");
include("inflector");
;
include.set_path('jmvc/plugins/lang/openajax');
if(!window["OpenAjax"]){
OpenAjax=new function(){
var t=true;
var f=false;
var g=window;
var _4="org.openajax.hub.";
var h={};
this.hub=h;
h.implementer="http://openajax.org";
h.implVersion="1.0";
h.specVersion="1.0";
h.implExtraData={};
var _6={};
h.libraries=_6;
h.registerLibrary=function(_7,_8,_9,_a){
_6[_7]={prefix:_7,namespaceURI:_8,version:_9,extraData:_a};
this.publish(_4+"registerLibrary",_6[_7]);
};
h.unregisterLibrary=function(_b){
this.publish(_4+"unregisterLibrary",_6[_b]);
delete _6[_b];
};
h._subscriptions={c:{},s:[]};
h._cleanup=[];
h._subIndex=0;
h._pubDepth=0;
h.subscribe=function(_c,_d,_e,_f,_10){
if(!_e){
_e=window;
}
var _11=_c+"."+this._subIndex;
var sub={scope:_e,cb:_d,fcb:_10,data:_f,sid:this._subIndex++,hdl:_11};
var _13=_c.split(".");
this._subscribe(this._subscriptions,_13,0,sub);
return _11;
};
h.publish=function(_14,_15){
var _16=_14.split(".");
this._pubDepth++;
this._publish(this._subscriptions,_16,0,_14,_15);
this._pubDepth--;
if((this._cleanup.length>0)&&(this._pubDepth==0)){
for(var i=0;i<this._cleanup.length;i++){
this.unsubscribe(this._cleanup[i].hdl);
}
delete (this._cleanup);
this._cleanup=[];
}
};
h.unsubscribe=function(sub){
var _19=sub.split(".");
var sid=_19.pop();
this._unsubscribe(this._subscriptions,_19,0,sid);
};
h._subscribe=function(_1b,_1c,_1d,sub){
var _1f=_1c[_1d];
if(_1d==_1c.length){
_1b.s.push(sub);
}else{
if(typeof _1b.c=="undefined"){
_1b.c={};
}
if(typeof _1b.c[_1f]=="undefined"){
_1b.c[_1f]={c:{},s:[]};
this._subscribe(_1b.c[_1f],_1c,_1d+1,sub);
}else{
this._subscribe(_1b.c[_1f],_1c,_1d+1,sub);
}
}
};
h._publish=function(_20,_21,_22,_23,msg,pcb,_26){
if(typeof _20!="undefined"){
var _27;
if(_22==_21.length){
_27=_20;
}else{
this._publish(_20.c[_21[_22]],_21,_22+1,_23,msg,pcb,_26);
this._publish(_20.c["*"],_21,_22+1,_23,msg,pcb,_26);
_27=_20.c["**"];
}
if(typeof _27!="undefined"){
var _28=_27.s;
var max=_28.length;
for(var i=0;i<max;i++){
if(_28[i].cb){
var sc=_28[i].scope;
var cb=_28[i].cb;
var fcb=_28[i].fcb;
var d=_28[i].data;
var sid=_28[i].sid;
var _30=_28[i].cid;
if(typeof cb=="string"){
cb=sc[cb];
}
if(typeof fcb=="string"){
fcb=sc[fcb];
}
if((!fcb)||(fcb.call(sc,_23,msg,d))){
if((!pcb)||(pcb(_23,msg,_26,_30))){
cb.call(sc,_23,msg,d,sid);
}
}
}
}
}
}
};
h._unsubscribe=function(_31,_32,_33,sid){
if(typeof _31!="undefined"){
if(_33<_32.length){
var _35=_31.c[_32[_33]];
this._unsubscribe(_35,_32,_33+1,sid);
if(_35.s.length==0){
for(var x in _35.c){
return;
}
delete _31.c[_32[_33]];
}
return;
}else{
var _37=_31.s;
var max=_37.length;
for(var i=0;i<max;i++){
if(sid==_37[i].sid){
if(this._pubDepth>0){
_37[i].cb=null;
this._cleanup.push(_37[i]);
}else{
_37.splice(i,1);
}
return;
}
}
}
}
};
h.reinit=function(){
for(var lib in OpenAjax.hub.libraries){
delete OpenAjax.hub.libraries[lib];
}
OpenAjax.hub.registerLibrary("OpenAjax","http://openajax.org/hub","1.0",{});
delete OpenAjax._subscriptions;
OpenAjax._subscriptions={c:{},s:[]};
delete OpenAjax._cleanup;
OpenAjax._cleanup=[];
OpenAjax._subIndex=0;
OpenAjax._pubDepth=0;
};
};
OpenAjax.hub.registerLibrary("OpenAjax","http://openajax.org/hub","1.0",{});
}
OpenAjax.hub.registerLibrary("JavaScriptMVC","http://JavaScriptMVC.com","1.5",{});
;
include.set_path('jmvc/plugins/view/helpers');
MVC.Object.extend(MVC.View.Helpers.prototype,{check_box_tag:function(_1,_2,_3,_4){
_3=_3||{};
if(_4){
_3.checked="checked";
}
return this.input_field_tag(_1,_2,"checkbox",_3);
},date_tag:function(_5,_6,_7){
if(!(_6 instanceof Date)){
_6=new Date();
}
var _8=[],_9=[],_a=[];
var _b=_6.getFullYear(),_c=_6.getMonth(),_d=_6.getDate();
for(var y=_b-15;y<_b+15;y++){
_8.push({value:y,text:y});
}
for(var m=0;m<12;m++){
_9.push({value:(m),text:MVC.Date.month_names[m]});
}
for(var d=0;d<31;d++){
_a.push({value:(d+1),text:(d+1)});
}
var _11=this.select_tag(_5+"[year]",_b,_8,{id:_5+"[year]"});
var _12=this.select_tag(_5+"[month]",_c,_9,{id:_5+"[month]"});
var _13=this.select_tag(_5+"[day]",_d,_a,{id:_5+"[day]"});
return _11+_12+_13;
},file_tag:function(_14,_15,_16){
return this.input_field_tag(_14+"[file]",_15,"file",_16);
},form_tag:function(_17,_18){
_18=_18||{};
if(_18.multipart==true){
_18.method="post";
_18.enctype="multipart/form-data";
}
_18.action=_17;
return this.start_tag_for("form",_18);
},form_tag_end:function(){
return this.tag_end("form");
},hidden_field_tag:function(_19,_1a,_1b){
return this.input_field_tag(_19,_1a,"hidden",_1b);
},input_field_tag:function(_1c,_1d,_1e,_1f){
_1f=_1f||{};
_1f.id=_1f.id||_1c;
_1f.value=_1d||"";
_1f.type=_1e||"text";
_1f.name=_1c;
return this.single_tag_for("input",_1f);
},label_tag:function(_20,_21){
_21=_21||{};
return this.start_tag_for("label",_21)+_20+this.tag_end("label");
},link_to:function(_22,url,_24){
if(!_22){
var _22="null";
}
if(!_24){
var _24={};
}
this.set_confirm(_24);
_24.href=url;
return this.start_tag_for("a",_24)+_22+this.tag_end("a");
},link_to_if:function(_25,_26,url,_28){
return this.link_to_unless((!_25),_26,url,_28);
},link_to_unless:function(_29,_2a,url,_2c){
if(_29){
return _2a;
}
return this.link_to(_2a,url,_2c);
},set_confirm:function(_2d){
if(_2d.confirm){
_2d.onclick=_2d.onclick||"";
_2d.onclick=_2d.onclick+"; var ret_confirm = confirm(\""+_2d.confirm+"\"); if(!ret_confirm){ return false;} ";
_2d.confirm=null;
}
},submit_link_to:function(_2e,_2f,_30,_31){
if(!_2e){
var _2e="null";
}
if(!_30){
_30={};
}
_30.type="submit";
_30.value=_2e;
this.set_confirm(_30);
_30.onclick=_30.onclick+";window.location=\""+_2f+"\"; return false;";
return this.single_tag_for("input",_30);
},password_field_tag:function(_32,_33,_34){
return this.input_field_tag(_32,_33,"password",_34);
},select_tag:function(_35,_36,_37,_38){
_38=_38||{};
_38.id=_38.id||_35;
_38.name=_35;
var txt="";
txt+=this.start_tag_for("select",_38);
for(var i=0;i<_37.length;i++){
var _3b=_37[i];
if(typeof _3b=="string"){
_3b={value:_3b};
}
if(!_3b.text){
_3b.text=_3b.value;
}
if(!_3b.value){
_3b.text=_3b.text;
}
var _3c={value:_3b.value};
if(_3b.value==_36){
_3c.selected="selected";
}
txt+=this.start_tag_for("option",_3c)+_3b.text+this.tag_end("option");
}
txt+=this.tag_end("select");
return txt;
},single_tag_for:function(tag,_3e){
return this.tag(tag,_3e,"/>");
},start_tag_for:function(tag,_40){
return this.tag(tag,_40);
},submit_tag:function(_41,_42){
_42=_42||{};
_42.type=_42.type||"submit";
_42.value=_41||"Submit";
return this.single_tag_for("input",_42);
},tag:function(tag,_44,end){
end=end||">";
var txt=" ";
for(var _47 in _44){
if(_44.hasOwnProperty(_47)){
value=_44[_47]!=null?_44[_47].toString():"";
if(_47=="Class"||_47=="klass"){
_47="class";
}
if(value.indexOf("'")!=-1){
txt+=_47+"=\""+value+"\" ";
}else{
txt+=_47+"='"+value+"' ";
}
}
}
return "<"+tag+txt+end;
},tag_end:function(tag){
return "</"+tag+">";
},text_area_tag:function(_49,_4a,_4b){
_4b=_4b||{};
_4b.id=_4b.id||_49;
_4b.name=_4b.name||_49;
_4a=_4a||"";
if(_4b.size){
_4b.cols=_4b.size.split("x")[0];
_4b.rows=_4b.size.split("x")[1];
delete _4b.size;
}
_4b.cols=_4b.cols||50;
_4b.rows=_4b.rows||4;
return this.start_tag_for("textarea",_4b)+_4a+this.tag_end("textarea");
},text_field_tag:function(_4c,_4d,_4e){
return this.input_field_tag(_4c,_4d,"text",_4e);
},img_tag:function(_4f,_50){
_50=_50||{};
_50.src="resources/images/"+_4f;
return this.single_tag_for("img",_50);
}});
MVC.View.Helpers.prototype.text_tag=MVC.View.Helpers.prototype.text_area_tag;
(function(){
var _51={};
var _52=0;
MVC.View.Helpers.link_data=function(_53){
var _54=_52++;
_51[_54]=_53;
return "_data='"+_54+"'";
};
MVC.View.Helpers.get_data=function(el){
if(!el){
return null;
}
var _56=el.getAttribute("_data");
if(!_56){
return null;
}
return _51[parseInt(_56)];
};
MVC.View.Helpers.prototype.link_data=function(_57){
return MVC.View.Helpers.link_data(_57);
};
MVC.View.Helpers.prototype.get_data=function(el){
return MVC.View.Helpers.get_data(el);
};
})();
;
include.set_path('resources/edit_area');
/******
 *
 *	EditArea 
 * 	Developped by Christophe Dolivet
 *	Released under LGPL license
 *
******/

	function EditAreaLoader(){
		this.version= "0.7.0.2";
		date= new Date();
		this.start_time=date.getTime();
		this.win= "loading";	// window loading state
		this.error= false;	// to know if load is interrrupt
		this.baseURL="";
		//this.suffix="";
		this.template="";
		this.lang= new Object();	// array of loaded speech language
		this.load_syntax= new Object();	// array of loaded syntax language for highlight mode
		this.syntax= new Object();	// array of initilized syntax language for highlight mode
		this.loadedFiles= new Array();
		this.waiting_loading= new Object(); 	// files that must be loaded in order to allow the script to really start
		// scripts that must be loaded in the iframe
		this.scripts_to_load= new Array("elements_functions", "resize_area", "reg_syntax");
		this.sub_scripts_to_load= new Array("edit_area", "manage_area" ,"edit_area_functions", "keyboard", "search_replace", "highlight", "regexp");
		
		this.resize= new Array(); // contain resizing datas
		this.hidden= new Object();	// store datas of the hidden textareas
		
		this.default_settings= {
			//id: "src"	// id of the textarea to transform
			debug: false
			,smooth_selection: true
			,font_size: "10"		// not for IE
			,font_family: "monospace"	// can be "verdana,monospace". Allow non monospace font but Firefox get smaller tabulation with non monospace fonts. IE doesn't change the tabulation width and Opera doesn't take this option into account... 
			,start_highlight: false	// if start with highlight			
			,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, |, help"
			,begin_toolbar: ""		//  "new_document, save, load, |"
			,end_toolbar: ""		// or end_toolbar
			,is_multi_files: false		// enable the multi file mode (the textarea content is ignored)
			,allow_resize: "both"	// possible values: "no", "both", "x", "y"
			,min_width: 400
			,min_height: 125
			,replace_tab_by_spaces: false
			,allow_toggle: true		// true or false
			,language: "en"
			,syntax: ""
			,syntax_selection_allow: "basic,brainfuck,c,cpp,css,html,js,pas,php,python,sql,vb,xml"
			,display: "onload" 		// onload or later
			,max_undo: 30
			,browsers: "known"	// all or known
			,plugins: "" // comma separated plugin list
			,gecko_spellcheck: false	// enable/disable by default the gecko_spellcheck
			,fullscreen: false
			,load_callback: ""		// click on load button (function name)
			,save_callback: ""		// click on save button (function name)
			,change_callback: ""	// textarea onchange trigger (function name)
			,submit_callback: ""	// form submited (function name)
			,EA_init_callback: ""	// EditArea initiliazed (function name)
			,EA_delete_callback: ""	// EditArea deleted (function name)
			,EA_load_callback: ""	// EditArea fully loaded and displayed (function name)
			,EA_unload_callback: ""	// EditArea delete while being displayed (function name)
			,EA_toggle_on_callback: ""	// EditArea toggled on (function name)
			,EA_toggle_off_callback: ""	// EditArea toggled off (function name)
			,EA_file_switch_on_callback: ""	// a new tab is selected (called for the newly selected file)
			,EA_file_switch_off_callback: ""	// a new tab is selected (called for the previously selected file)
			,EA_file_close_callback: ""		// close a tab
		};
		
		this.advanced_buttons = [
				// id, button img, command (it will try to find the translation of "id"), is_file_specific
				['new_document', 'newdocument.gif', 'new_document', false],
				['search', 'search.gif', 'show_search', false],
				['go_to_line', 'go_to_line.gif', 'go_to_line', false],
				['undo', 'undo.gif', 'undo', true],
				['redo', 'redo.gif', 'redo', true],
				['change_smooth_selection', 'smooth_selection.gif', 'change_smooth_selection_mode', true],
				['reset_highlight', 'reset_highlight.gif', 'resync_highlight', true],
				['highlight', 'highlight.gif','change_highlight', true],
				['help', 'help.gif', 'show_help', false],
				['save', 'save.gif', 'save', false],
				['load', 'load.gif', 'load', false],
				['fullscreen', 'fullscreen.gif', 'toggle_full_screen', false]
			];
				
		// navigator identification
		ua= navigator.userAgent;
		
		this.nav= new Object(); 
		this.nav['isIE'] = (navigator.appName == "Microsoft Internet Explorer");
		if(this.nav['isIE']){
			this.nav['isIE'] = ua.replace(/^.*?MSIE ([0-9\.]*).*$/, "$1");
			if( this.nav['isIE'] < 6 ){
				this.has_error(); 
			}
		}
		if( (this.nav['isNS'] = (ua.indexOf('Netscape/') != -1)) ){	// work only on netscape > 8 with render mode IE
			this.nav['isNS']= ua.substr(ua.indexOf('Netscape/')+9);
			if(this.nav['isNS']<8 || !this.nav['isIE'])
				this.has_error();			
		}
		
		if((this.nav['isOpera'] = (ua.indexOf('Opera') != -1))){	
			this.nav['isOpera']= ua.replace(/^.*?Opera.*?([0-9\.]+).*$/i, "$1");
			if(this.nav['isOpera']<9)
				this.has_error();
			this.nav['isIE']=false;			
		}
		this.nav['isGecko'] = (ua.indexOf('Gecko') != -1);
		
		if((this.nav['isFirefox'] =(ua.indexOf('Firefox') != -1)))
			this.nav['isFirefox'] = ua.replace(/^.*?Firefox.*?([0-9\.]+).*$/i, "$1");
		// Iceweasel is a clone of Firefox 	
		if((this.nav['isIceweasel'] =(ua.indexOf('Iceweasel') != -1)))
			this.nav['isFirefox']= this.nav['isIceweasel'] = ua.replace(/^.*?Iceweasel.*?([0-9\.]+).*$/i, "$1");
		
		if((this.nav['isCamino'] =(ua.indexOf('Camino') != -1)))
			this.nav['isCamino'] = ua.replace(/^.*?Camino.*?([0-9\.]+).*$/i, "$1");
		
		if((this.nav['isSafari'] =(ua.indexOf('Safari') != -1)))
			this.nav['isSafari']= ua.replace(/^.*?Version\/([0-9]+\.[0-9]+).*$/i, "$1");
		
		if(this.nav['isIE']>=6 || this.nav['isOpera']>=9 || this.nav['isFirefox'] || this.nav['isCamino'] || this.nav['isSafari']>=3)
			this.nav['isValidBrowser']=true;
		else
			this.nav['isValidBrowser']=false;
	
		this.set_base_url();		
		
		for(var i=0; i<this.scripts_to_load.length; i++){
			include(this.scripts_to_load[i]);	// let the time to Object editAreaLoader to be created before loading additionnal scripts
			this.waiting_loading[this.scripts_to_load[i]+ ".js"]= false;
		}				
		this.add_event(window, "load", EditAreaLoader.prototype.window_loaded);
	};
	
	EditAreaLoader.prototype.has_error= function(){
		this.error= true;
		// set to empty all EditAreaLoader functions
		for(var i in EditAreaLoader.prototype){
			EditAreaLoader.prototype[i]=function(){};		
		}
	};
	
	EditAreaLoader.prototype.window_loaded= function(){
		editAreaLoader.win="loaded";

		// add events on forms
		if (document.forms) {
			for (var i=0; i<document.forms.length; i++) {
				var form = document.forms[i];
				form.edit_area_replaced_submit=null;
				try {
					
					form.edit_area_replaced_submit = form.onsubmit;
					form.onsubmit="";
				} catch (e) {// Do nothing
				}
				editAreaLoader.add_event(form, "submit", EditAreaLoader.prototype.submit);
				editAreaLoader.add_event(form, "reset", EditAreaLoader.prototype.reset);
			}
		}
		
		
	/*	if(editAreaLoader.nav['isIE']){	// launch IE selection checkup
			for(var i in editAreas){
				editAreaLoader.init_ie_textarea(i);
			}
		}*/
		editAreaLoader.add_event(window, "unload", function(){for(var i in editAreas){editAreaLoader.delete_instance(i);}});	// ini callback
	};
	
	// init the checkup of the selection of the IE textarea
	EditAreaLoader.prototype.init_ie_textarea= function(id){
		textarea=document.getElementById(id);
		if(textarea && typeof(textarea.focused)=="undefined"){
			textarea.focus();
			textarea.focused=true;
			textarea.selectionStart= textarea.selectionEnd= 0;			
			get_IE_selection(textarea);
			editAreaLoader.add_event(textarea, "focus", IE_textarea_focus);
			editAreaLoader.add_event(textarea, "blur", IE_textarea_blur);
			
		}
	};
		
	EditAreaLoader.prototype.init= function(settings){
	
		if(!settings["id"])
			this.has_error();
		
		if(this.error)
			return;
		// if an instance of the editor already exists for this textarea => delete the previous one
		if(editAreas[settings["id"]])
			editAreaLoader.delete_instance(settings["id"]);
	
		// init settings
		for(var i in this.default_settings){
			if(typeof(settings[i])=="undefined")
				settings[i]=this.default_settings[i];
		}
		
		if(settings["browsers"]=="known" && this.nav['isValidBrowser']==false){
			return;
		}
		
		if(settings["begin_toolbar"].length>0)
			settings["toolbar"]= settings["begin_toolbar"] +","+ settings["toolbar"];
		if(settings["end_toolbar"].length>0)
			settings["toolbar"]= settings["toolbar"] +","+ settings["end_toolbar"];
		settings["tab_toolbar"]= settings["toolbar"].replace(/ /g,"").split(",");
		
		settings["plugins"]= settings["plugins"].replace(/ /g,"").split(",");
		for(var i=0; i<settings["plugins"].length; i++){
			if(settings["plugins"][i].length==0)
				settings["plugins"].splice(i,1);
		}
	//	alert(settings["plugins"].length+": "+ settings["plugins"].join(","));
	/*	var tmp="";
		for(var i in settings){
			tmp+=i+" : "+settings[i]+";\n";
		}
		alert(tmp);*/
		this.get_template();
		//alert('lang '+include.get_path()+' ... langs/'+ settings["language"])
		include(this.baseURL+"langs/"+ settings["language"]);
		
		if(settings["syntax"].length>0){
			settings["syntax"]=settings["syntax"].toLowerCase();
			include(this.baseURL+"reg_syntax/"+ settings["syntax"]);
		}
		//alert(this.template);
		
		editAreas[settings["id"]]= {"settings": settings};
		editAreas[settings["id"]]["displayed"]=false;
		editAreas[settings["id"]]["hidden"]=false;
		
		//if(settings["display"]=="onload")
		editAreaLoader.start(settings["id"]);
	};
	
	// delete an instance of an EditArea
	EditAreaLoader.prototype.delete_instance= function(id){
		
		editAreaLoader.execCommand(id, "EA_delete");
		if(window.frames["frame_"+id] && window.frames["frame_"+id].editArea)
		{
			if(editAreas[id]["displayed"])
				editAreaLoader.toggle(id, "off");
			window.frames["frame_"+id].editArea.execCommand("EA_unload");
		}

		// remove toggle infos and debug textarea
		var span= document.getElementById("EditAreaArroundInfos_"+id);
		if(span){
			span.parentNode.removeChild(span);
		}

		// remove the iframe
		var iframe= document.getElementById("frame_"+id);
		if(iframe){
			iframe.parentNode.removeChild(iframe);
			//delete iframe;
			try {
				delete window.frames["frame_"+id];
			} catch (e) {// Do nothing
			}
		}	

		delete editAreas[id];

	};

	
	EditAreaLoader.prototype.start= function(id){
		// check that the window is loaded
		if(this.win!="loaded"){
			setTimeout("editAreaLoader.start('"+id+"');", 50);
			return;
		}
		
		// check that all needed scripts are loaded
		for(var i in editAreaLoader.waiting_loading){
			if(editAreaLoader.waiting_loading[i]!="loaded"){
				setTimeout("editAreaLoader.start('"+id+"');", 50);
				return;
			}
		}
		
		// wait until language and syntax files are loaded
		if(!editAreaLoader.lang[editAreas[id]["settings"]["language"]] || (editAreas[id]["settings"]["syntax"].length>0 && !editAreaLoader.load_syntax[editAreas[id]["settings"]["syntax"]]) ){
			setTimeout("editAreaLoader.start('"+id+"');", 50);
			return;
		}
		// init the regexp for syntax highlight
		if(editAreas[id]["settings"]["syntax"].length>0)
			editAreaLoader.init_syntax_regexp();
		
			
		// display toggle option and debug area
		if(!document.getElementById("EditAreaArroundInfos_"+id) && (editAreas[id]["settings"]["debug"] || editAreas[id]["settings"]["allow_toggle"]))
		{
			var span= document.createElement("span");
			span.id= "EditAreaArroundInfos_"+id;
			var html="";
			if(editAreas[id]["settings"]["allow_toggle"]){
				checked=(editAreas[id]["settings"]["display"]=="onload")?"checked":"";
				html+="<div id='edit_area_toggle_"+i+"'>";
				html+="<input id='edit_area_toggle_checkbox_"+ id +"' class='toggle_"+ id +"' type='checkbox' onclick='editAreaLoader.toggle(\""+ id +"\");' accesskey='e' "+checked+" />";
				html+="<label for='edit_area_toggle_checkbox_"+ id +"'>{$toggle}</label></div>";	
			}
			if(editAreas[id]["settings"]["debug"])
				html+="<textarea id='edit_area_debug_"+ id +"' style='z-index: 20; width: 100%; height: 120px;overflow: auto; border: solid black 1px;'></textarea><br />";				
			html= editAreaLoader.translate(html, editAreas[id]["settings"]["language"]);				
			span.innerHTML= html;				
			var father= document.getElementById(id).parentNode;
			var next= document.getElementById(id).nextSibling;
			if(next==null)
				father.appendChild(span);
			else
				father.insertBefore(span, next);
		}
		
		if(!editAreas[id]["initialized"])
		{
			this.execCommand(id, "EA_init");	// ini callback
			if(editAreas[id]["settings"]["display"]=="later"){
				editAreas[id]["initialized"]= true;
				return;
			}
		}
		
		if(this.nav['isIE']){	// launch IE selection checkup
			editAreaLoader.init_ie_textarea(id);
		}
				
		// get toolbar content
		var html_toolbar_content="";
		area=editAreas[id];
		
		for(var i=0; i<area["settings"]["tab_toolbar"].length; i++){
		//	alert(this.tab_toolbar[i]+"\n"+ this.get_control_html(this.tab_toolbar[i]));
			html_toolbar_content+= this.get_control_html(area["settings"]["tab_toolbar"][i], area["settings"]["language"]);
		}
		
		// create javascript import rules for the iframe if the javascript has not been already loaded by the compressor
		if(!this.iframe_script){
			this.iframe_script="";
			for(var i=0; i<this.sub_scripts_to_load.length; i++)
				this.iframe_script+='<script language="javascript" type="text/javascript" src="'+ this.baseURL + this.sub_scripts_to_load[i] +'.js"></script>';
		}
		
		// add plugins scripts if not already loaded by the compressor (but need to load language in all the case)
		for(var i=0; i<area["settings"]["plugins"].length; i++){
			//if(typeof(area["settings"]["plugins"][i])=="function") continue;
			if(!editAreaLoader.all_plugins_loaded)
				this.iframe_script+='<script language="javascript" type="text/javascript" src="'+ this.baseURL + 'plugins/' + area["settings"]["plugins"][i] + '/' + area["settings"]["plugins"][i] +'.js"></script>';
			this.iframe_script+='<script language="javascript" type="text/javascript" src="'+ this.baseURL + 'plugins/' + area["settings"]["plugins"][i] + '/langs/' + area["settings"]["language"] +'.js"></script>';
		}
	
		
		// create css link for the iframe if the whole css text has not been already loaded by the compressor
		if(!this.iframe_css){
			this.iframe_css="<link href='"+ this.baseURL +"edit_area.css' rel='stylesheet' type='text/css' />";
		}
		
		
		// create template
		var template= this.template.replace(/\[__BASEURL__\]/g, this.baseURL);
		template= template.replace("[__TOOLBAR__]",html_toolbar_content);
			
		
		// fill template with good language sentences
		template= this.translate(template, area["settings"]["language"], "template");
		
		// add css_code
		template= template.replace("[__CSSRULES__]", this.iframe_css);				
		// add js_code
		template= template.replace("[__JSCODE__]", this.iframe_script);
		
		// add version_code
		template= template.replace("[__EA_VERSION__]", this.version);
		//template=template.replace(/\{\MVC.$E([^\}]+)\}/gm, this.traduc_template);
		
		//editAreas[area["settings"]["id"]]["template"]= template;
		
		area.textarea=document.getElementById(area["settings"]["id"]);
		editAreas[area["settings"]["id"]]["textarea"]=area.textarea;
	
		
		// insert template in the document after the textarea
		var father= area.textarea.parentNode;
	/*	var container= document.createElement("div");
		container.id= "EditArea_frame_container_"+area["settings"]["id"];
	*/	
		var content= document.createElement("iframe");
		content.name= "frame_"+area["settings"]["id"];
		content.id= "frame_"+area["settings"]["id"];
		content.style.borderWidth= "0px";
		setAttribute(content, "frameBorder", "0"); // IE
		content.style.overflow="hidden";
		content.style.display="none";
		
	/*	container.appendChild(content);
		var next= area.textarea.nextSibling;
		if(next==null)
			father.appendChild(container);
		else
			father.insertBefore(container, next) ;*/
		
		var next= area.textarea.nextSibling;
		if(next==null)
			father.appendChild(content);
		else
			father.insertBefore(content, next) ;		
		var frame=window.frames["frame_"+area["settings"]["id"]];		
		
		frame.document.open();
		frame.editAreas=editAreas;
		frame.area_id= area["settings"]["id"];	
		frame.document.area_id= area["settings"]["id"];	
		frame.document.write(template);
		frame.document.close();

	//	frame.editAreaLoader=this;
		//editAreas[area["settings"]["id"]]["displayed"]=true;
		
	};
	
	EditAreaLoader.prototype.toggle= function(id, toggle_to){

	/*	if((editAreas[id]["displayed"]==true  && toggle_to!="on") || toggle_to=="off"){
			this.toggle_off(id);
		}else if((editAreas[id]["displayed"]==false  && toggle_to!="off") || toggle_to=="on"){
			this.toggle_on(id);
		}*/
		if(!toggle_to)
			toggle_to= (editAreas[id]["displayed"]==true)?"off":"on";
		if(editAreas[id]["displayed"]==true  && toggle_to=="off"){
			this.toggle_off(id);
		}else if(editAreas[id]["displayed"]==false  && toggle_to=="on"){
			this.toggle_on(id);
		}
	
		return false;
	};
	
	EditAreaLoader.prototype.toggle_off= function(id){
		if(window.frames["frame_"+id])
		{	
			var frame=window.frames["frame_"+id];
			if(frame.editArea.fullscreen['isFull'])
				frame.editArea.toggle_full_screen(false);
			editAreas[id]["displayed"]=false;
			
			// set wrap to off to keep same display mode (some browser get problem with this, so it need more complex operation
			
			editAreas[id]["textarea"].wrap = "off";	// for IE
			setAttribute(editAreas[id]["textarea"], "wrap", "off");	// for Firefox	
			var parNod = editAreas[id]["textarea"].parentNode;
			var nxtSib = editAreas[id]["textarea"].nextSibling;
			parNod.removeChild(editAreas[id]["textarea"]); 
			parNod.insertBefore(editAreas[id]["textarea"], nxtSib);
			
			// restore values
			editAreas[id]["textarea"].value= frame.editArea.textarea.value;
			var selStart= frame.editArea.last_selection["selectionStart"];
			var selEnd= frame.editArea.last_selection["selectionEnd"];
			var scrollTop= frame.document.getElementById("result").scrollTop;
			var scrollLeft= frame.document.getElementById("result").scrollLeft;
			
			
			document.getElementById("frame_"+id).style.display='none';
		
			editAreas[id]["textarea"].style.display="inline";


			editAreas[id]["textarea"].focus();	
			if(this.nav['isIE']){
				editAreas[id]["textarea"].selectionStart= selStart;
				editAreas[id]["textarea"].selectionEnd= selEnd;
				editAreas[id]["textarea"].focused=true;
				set_IE_selection(editAreas[id]["textarea"]);
			}else{
				if(this.nav['isOpera']){	// Opera bug when moving selection start and selection end
					editAreas[id]["textarea"].setSelectionRange(0, 0);
				}
				try{
					editAreas[id]["textarea"].setSelectionRange(selStart, selEnd);
				} catch(e) {
				};
			}
			editAreas[id]["textarea"].scrollTop= scrollTop;
			editAreas[id]["textarea"].scrollLeft= scrollLeft;
			frame.editArea.execCommand("toggle_off");

		}
	};	
	
	EditAreaLoader.prototype.toggle_on= function(id){
		/*if(!editAreas[area["settings"]["id"]]["started"])
			editAreaLoader.start(id);*/
			
		if(window.frames["frame_"+id])
		{
			var frame=window.frames["frame_"+id];
			area= window.frames["frame_"+id].editArea;
			area.textarea.value= editAreas[id]["textarea"].value;
			
			// store display values;
			var selStart= 0;
			var selEnd= 0;
			var scrollTop= 0;
			var scrollLeft= 0;

			if(editAreas[id]["textarea"].use_last==true)
			{
				var selStart= editAreas[id]["textarea"].last_selectionStart;
				var selEnd= editAreas[id]["textarea"].last_selectionEnd;
				var scrollTop= editAreas[id]["textarea"].last_scrollTop;
				var scrollLeft= editAreas[id]["textarea"].last_scrollLeft;
				editAreas[id]["textarea"].use_last=false;
			}
			else
			{
				try{
					var selStart= editAreas[id]["textarea"].selectionStart;
					var selEnd= editAreas[id]["textarea"].selectionEnd;
					var scrollTop= editAreas[id]["textarea"].scrollTop;
					var scrollLeft= editAreas[id]["textarea"].scrollLeft;
					//alert(scrollTop);
				}catch(ex){}
			}
			
			// set to good size
			this.set_editarea_size_from_textarea(id, document.getElementById("frame_"+id));
			editAreas[id]["textarea"].style.display="none";			
			document.getElementById("frame_"+id).style.display="inline";
			area.execCommand("focus"); // without this focus opera doesn't manage well the iframe body height
			
			
			// restore display values
			editAreas[id]["displayed"]=true;
			area.execCommand("update_size");
			
			window.frames["frame_"+id].document.getElementById("result").scrollTop= scrollTop;
			window.frames["frame_"+id].document.getElementById("result").scrollLeft= scrollLeft;
			area.area_select(selStart, selEnd-selStart);
			area.execCommand("toggle_on");

			/*date= new Date();
			end_time=date.getTime();		
			alert("load time: "+ (end_time-this.start_time));*/
			
		}
		else
		{
		/*	if(this.nav['isIE'])
				get_IE_selection(document.getElementById(id));	*/	
			var elem= document.getElementById(id);	
			elem.last_selectionStart= elem.selectionStart;
			elem.last_selectionEnd= elem.selectionEnd;
			elem.last_scrollTop= elem.scrollTop;
			elem.last_scrollLeft= elem.scrollLeft;
			elem.use_last=true;
			editAreaLoader.start(id);
		}
	};	
	
	EditAreaLoader.prototype.set_editarea_size_from_textarea= function(id, frame){	
		var elem= document.getElementById(id);
		//var width= elem.offsetWidth+"px";
		//var height= elem.offsetHeight+"px";
		var width=Math.max(editAreas[id]["settings"]["min_width"], elem.offsetWidth)+"px";
		var height=Math.max(editAreas[id]["settings"]["min_height"], elem.offsetHeight)+"px";
		if(elem.style.width.indexOf("%")!=-1)
			width= elem.style.width;
		if(elem.style.height.indexOf("%")!=-1)
			height= elem.style.height;
		//alert("h: "+height+" w: "+width);
	
		frame.style.width= width;
		frame.style.height= height;
	};
		
	EditAreaLoader.prototype.set_base_url= function(){
		//this.baseURL="";
		this.baseURL = include.get_absolute_path()+'/';
		this.file_name = 'edit_area_loader.js';
		return;
		
		if (!this.baseURL) {
			var elements = document.getElementsByTagName('script');
	
			for (var i=0; i<elements.length; i++) {
				if (elements[i].src && elements[i].src.match(/edit_area_[^\\\/]*$/i) ) {
					var src = elements[i].src;
					src = src.substring(0, src.lastIndexOf('/'));
					this.baseURL = src;
					this.file_name= elements[i].src.substr(elements[i].src.lastIndexOf("/")+1);
					break;
				}
			}
		}
		
		var documentBasePath = document.location.href;
		if (documentBasePath.indexOf('?') != -1)
			documentBasePath = documentBasePath.substring(0, documentBasePath.indexOf('?'));
		var documentURL = documentBasePath;
		documentBasePath = documentBasePath.substring(0, documentBasePath.lastIndexOf('/'));
	
		// If not HTTP absolute
		if (this.baseURL.indexOf('://') == -1 && this.baseURL.charAt(0) != '/') {
			// If site absolute
			this.baseURL = documentBasePath + "/" + this.baseURL;
		}
		this.baseURL+="/";	
	};
	
	EditAreaLoader.prototype.get_button_html= function(id, img, exec, isFileSpecific, baseURL) {
		if(!baseURL)
			baseURL= this.baseURL;
		var cmd = 'editArea.execCommand(\'' + exec + '\')';
		html= '<a id="a_'+ id +'" href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self" fileSpecific="'+ (isFileSpecific?'yes':'no') +'">';
		html+= '<img id="' + id + '" src="'+ baseURL +'images/' + img + '" title="{$' + id + '}" width="20" height="20" class="editAreaButtonNormal" onmouseover="editArea.switchClass(this,\'editAreaButtonOver\');" onmouseout="editArea.restoreClass(this);" onmousedown="editArea.restoreAndSwitchClass(this,\'editAreaButtonDown\');" /></a>';
		return html;
	};

	EditAreaLoader.prototype.get_control_html= function(button_name, lang) {		
		
		for (var i=0; i<this.advanced_buttons.length; i++)
		{
			var but = this.advanced_buttons[i];			
			if (but[0] == button_name)
			{
				return this.get_button_html(but[0], but[1], but[2], but[3]);
			}	
		}		
				
		switch (button_name){
			case "*":
			case "return":
				return "<br />";
			case "|":
		  	case "separator":
				return '<img src="'+ this.baseURL +'images/spacer.gif" width="1" height="15" class="editAreaSeparatorLine">';
			case "select_font":
				html= "<select id='area_font_size' onchange='javascript:editArea.execCommand(\"change_font_size\")' fileSpecific='yes'>"
					+"			<option value='-1'>{$font_size}</option>"
					+"			<option value='8'>8 pt</option>"
					+"			<option value='9'>9 pt</option>"
					+"			<option value='10'>10 pt</option>"
					+"			<option value='11'>11 pt</option>"
					+"			<option value='12'>12 pt</option>"
					+"			<option value='14'>14 pt</option>"
					+"		</select>";
				return html;
			case "syntax_selection":
				var html= "<select id='syntax_selection' onchange='javascript:editArea.execCommand(\"change_syntax\", this.value)' fileSpecific='yes'>";
				html+="<option value='-1'>{$syntax_selection}</option>";
				html+="</select>";
				return html;
		}
		
		return "<span id='tmp_tool_"+button_name+"'>["+button_name+"]</span>";		
	};
	
	
	EditAreaLoader.prototype.get_template= function() {
		if(this.template=="")
		{
			var xhr_object = null; 
			if(window.XMLHttpRequest) // Firefox 
				xhr_object = new XMLHttpRequest(); 
			else if(window.ActiveXObject) // Internet Explorer 
				xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
			else { // XMLHttpRequest not supported
				alert("XMLHTTPRequest not supported. EditArea not loaded"); 
				return; 
			} 
			xhr_object.open("GET", this.baseURL+"template.html", false); 
			xhr_object.send(null); 
			if(xhr_object.readyState == 4) 
				this.template=xhr_object.responseText;
			else
				this.has_error();
		}
	};
	
	// translate text
	EditAreaLoader.prototype.translate= function(text, lang, mode) {
		
		if(mode=="word")
			text=editAreaLoader.get_word_translation(text, lang);
		else if(mode="template"){
			editAreaLoader.current_language= lang;
			text=text.replace(/\{\MVC.$E([^\}]+)\}/gm, editAreaLoader.translate_template);
		}
		return text;
	};
	
	EditAreaLoader.prototype.translate_template= function(){
		return editAreaLoader.get_word_translation(EditAreaLoader.prototype.translate_template.arguments[1], editAreaLoader.current_language);
	};
	
	EditAreaLoader.prototype.get_word_translation= function(val, lang){
		for(var i in editAreaLoader.lang[lang]){
			if(i == val)
				return editAreaLoader.lang[lang][i];
		}
		return "_"+val;
	};
	
	EditAreaLoader.prototype.load_script= function(url){
		if (this.loadedFiles[url])
			return;	
		//alert("load: "+url);

		include(url);
		/*try{;
			var script= document.createElement("script");
			script.type= "text/javascript";
			script.src= url;
			script.charset= "UTF-8";
			var head= document.getElementsByTagName("head");
			head[0].appendChild(script);
		}catch(e){
			document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '" charset="UTF-8"></sc'+'ript>');
		}
		//var filename= url.replace(/^.*?\/?([a-z\.\_\-]+)$/i, "$1");*/
		this.loadedFiles[url] = true;
	};
	
	EditAreaLoader.prototype.add_event = function(obj, name, handler) {
		if (obj.attachEvent) {
			obj.attachEvent("on" + name, handler);
		} else{
			obj.addEventListener(name, handler, false);
		}
	};
	
	EditAreaLoader.prototype.remove_event = function(obj, name, handler){
		if (obj.detachEvent)
			obj.detachEvent("on" + name, handler);
		else
			obj.removeEventListener(name, handler, false);
	};


	// reset all the editareas in the form that have been reseted
	EditAreaLoader.prototype.reset= function(e){
		
		var formObj = editAreaLoader.nav['isIE'] ? window.event.srcElement : e.target;
		for(var i in editAreas){			
			var is_child= false;
			for (var x=0;x<formObj.elements.length;x++) {
				if(formObj.elements[x].id == i)
					is_child=true;
			}
			
			if(window.frames["frame_"+i] && is_child && editAreas[i]["displayed"]==true){
			
				var exec= 'window.frames["frame_'+ i +'"].editArea.textarea.value= document.getElementById("'+ i +'").value;';
				exec+= 'window.frames["frame_'+ i +'"].editArea.execCommand("focus");';
				exec+= 'window.frames["frame_'+ i +'"].editArea.check_line_selection();';
				exec+= 'window.frames["frame_'+ i +'"].editArea.execCommand("reset");';
				window.setTimeout(exec, 10);
			}
		}		
		return;
	};
	
	
	// prepare all the textarea replaced by an editarea to be submited
	EditAreaLoader.prototype.submit= function(e){		
		var formObj = editAreaLoader.nav['isIE'] ? window.event.srcElement : e.target;

		for(var i in editAreas){
			var is_child= false;
			for (var x=0;x<formObj.elements.length;x++) {
				if(formObj.elements[x].id == i)
					is_child=true;
			}
		
			if(is_child)
			{
				if(window.frames["frame_"+i] && editAreas[i]["displayed"]==true)
					document.getElementById(i).value= window.frames["frame_"+ i].editArea.textarea.value;
				editAreaLoader.execCommand(i,"EA_submit");
			}
		}				
		if(typeof(formObj.edit_area_replaced_submit) == "function"){
			res= formObj.edit_area_replaced_submit();
			if(res==false){
				if(editAreaLoader.nav['isIE'])
					return false;
				else
					e.preventDefault();
			}
		}
		return ;
	};
	
	// allow to get the value of the editarea
	EditAreaLoader.prototype.getValue = function(id){
        if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
            return window.frames["frame_"+ id].editArea.textarea.value;       
        }else if(elem=document.getElementById(id)){
        	return elem.value;
        }
        return false;
    };
    
    // allow to set the value of the editarea
    EditAreaLoader.prototype.setValue = function(id, new_val){
        if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
            window.frames["frame_"+ id].editArea.textarea.value= new_val;     
			window.frames["frame_"+ id].editArea.execCommand("focus"); 
			window.frames["frame_"+ id].editArea.check_line_selection(false);  
			window.frames["frame_"+ id].editArea.execCommand("onchange");
        }else if(elem=document.getElementById(id)){
        	elem.value= new_val;
        }
    };
    
    // allow to get infos on the selection: array(start, end)
    EditAreaLoader.prototype.getSelectionRange = function(id){
    	var sel= {"start": 0, "end": 0};
        if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
        	var editArea= window.frames["frame_"+ id].editArea;
           
		/*	if(this.nav['isIE']){
				editArea.getIESelection();
				
			}
			sel["start"]=editArea.textarea.selectionStart;
			sel["end"]=editArea.textarea.selectionEnd;
		*/
			sel["start"]=editArea.textarea.selectionStart;
			sel["end"]=editArea.textarea.selectionEnd;
		
        }else if(elem=document.getElementById(id)){
        	sel= getSelectionRange(elem);
        }
        return sel;
    };
    
    // allow to set the selection with the given start and end positions
    EditAreaLoader.prototype.setSelectionRange = function(id, new_start, new_end){
        if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
            window.frames["frame_"+ id].editArea.area_select(new_start, new_end-new_start);  
			// make an auto-scroll to the selection
			if(!this.nav['isIE']){
				window.frames["frame_"+ id].editArea.check_line_selection(false); 
				window.frames["frame_"+ id].editArea.scroll_to_view();
			}   
        }else if(elem=document.getElementById(id)){
        	setSelectionRange(elem, new_start, new_end);
        }
    };
    
    EditAreaLoader.prototype.getSelectedText = function(id){
    	var sel= this.getSelectionRange(id);
        return this.getValue(id).substring(sel["start"], sel["end"]);
    };
	
	EditAreaLoader.prototype.setSelectedText = function(id, new_val){
		new_val= new_val.replace(/\r/g, ""); 
		var sel= this.getSelectionRange(id);
		var text= this.getValue(id);
		if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
			var scrollTop= window.frames["frame_"+ id].document.getElementById("result").scrollTop;
			var scrollLeft= window.frames["frame_"+ id].document.getElementById("result").scrollLeft;
		}else{
			var scrollTop= document.getElementById(id).scrollTop;
			var scrollLeft= document.getElementById(id).scrollLeft;
		}
		
		text= text.substring(0, sel["start"])+ new_val +text.substring(sel["end"]);
		this.setValue(id, text);
		var new_sel_end= sel["start"]+ new_val.length;
		this.setSelectionRange(id, sel["start"], new_sel_end);
		
		
		// fix \r problem for selection length count on IE & Opera
		if(new_val != this.getSelectedText(id).replace(/\r/g, "")){
			this.setSelectionRange(id, sel["start"], new_sel_end+ new_val.split("\n").length -1);
		}
		// restore scrolling position
		if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
			window.frames["frame_"+ id].document.getElementById("result").scrollTop= scrollTop;
			window.frames["frame_"+ id].document.getElementById("result").scrollLeft= scrollLeft;
			window.frames["frame_"+ id].editArea.execCommand("onchange");
		}else{
			document.getElementById(id).scrollTop= scrollTop;
			document.getElementById(id).scrollLeft= scrollLeft;
		}
    };
    
    EditAreaLoader.prototype.insertTags = function(id, open_tag, close_tag){
    	var old_sel= this.getSelectionRange(id);
    	text= open_tag + this.getSelectedText(id) + close_tag; 
		editAreaLoader.setSelectedText(id, text);
    	var new_sel= this.getSelectionRange(id);
    	if(old_sel["end"] > old_sel["start"])	// if text was selected, cursor at the end
    		this.setSelectionRange(id, new_sel["end"], new_sel["end"]);
    	else // cursor in the middle
    		this.setSelectionRange(id, old_sel["start"]+open_tag.length, old_sel["start"]+open_tag.length);
    };
    
    // hide both EditArea and normal textarea
	EditAreaLoader.prototype.hide= function(id){
		if(document.getElementById(id) && !this.hidden[id])
		{
			this.hidden[id]= new Object();
			this.hidden[id]["selectionRange"]= this.getSelectionRange(id);
			if(document.getElementById(id).style.display!="none")
			{
				this.hidden[id]["scrollTop"]= document.getElementById(id).scrollTop;
				this.hidden[id]["scrollLeft"]= document.getElementById(id).scrollLeft;
			}
					
			if(window.frames["frame_"+id])
			{
				this.hidden[id]["toggle"]= editAreas[id]["displayed"];
				
				if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
					var scrollTop= window.frames["frame_"+ id].document.getElementById("result").scrollTop;
					var scrollLeft= window.frames["frame_"+ id].document.getElementById("result").scrollLeft;
				}else{
					var scrollTop= document.getElementById(id).scrollTop;
					var scrollLeft= document.getElementById(id).scrollLeft;
				}
				this.hidden[id]["scrollTop"]= scrollTop;
				this.hidden[id]["scrollLeft"]= scrollLeft;
				
				if(editAreas[id]["displayed"]==true)
					editAreaLoader.toggle_off(id);
			}
			
			// hide toggle button and debug box
			var span= document.getElementById("EditAreaArroundInfos_"+id);
			if(span){
				span.style.display='none';
			}
			
			// hide textarea
			document.getElementById(id).style.display= "none";
		}
	};
	
	// restore hidden EditArea and normal textarea
	EditAreaLoader.prototype.show= function(id){
		if((elem=document.getElementById(id)) && this.hidden[id])
		{
			elem.style.display= "inline";
			elem.scrollTop= this.hidden[id]["scrollTop"];
			elem.scrollLeft= this.hidden[id]["scrollLeft"];
			var span= document.getElementById("EditAreaArroundInfos_"+id);
			if(span){
				span.style.display='inline';
			}
			
			if(window.frames["frame_"+id])
			{
								
				// restore toggle button and debug box
			
				
				// restore textarea
				elem.style.display= "inline";
				
				// restore EditArea
				if(this.hidden[id]["toggle"]==true)
					editAreaLoader.toggle_on(id);
				
				scrollTop= this.hidden[id]["scrollTop"];
				scrollLeft= this.hidden[id]["scrollLeft"];
				
				if(window.frames["frame_"+id] && editAreas[id]["displayed"]==true){
					window.frames["frame_"+ id].document.getElementById("result").scrollTop= scrollTop;
					window.frames["frame_"+ id].document.getElementById("result").scrollLeft= scrollLeft;
				}else{
					elem.scrollTop= scrollTop;
					elem.scrollLeft= scrollLeft;
				}
			
			}
			// restore selection
			sel= this.hidden[id]["selectionRange"];
			this.setSelectionRange(id, sel["start"], sel["end"]);
			delete this.hidden[id];	
		}
	};
	
	// get the current file datas (for multi file editing mode)
	EditAreaLoader.prototype.getCurrentFile = function(id){
		return this.execCommand(id, 'get_file', this.execCommand(id, 'curr_file'));
	};
	EditAreaLoader.prototype.getRenameFile = function(id, file_id, new_id, new_title){
		return this.execCommand(id, 'rename_file', {id: file_id, new_id: new_id, new_title: new_title} );
	};
	// get the given file datas (for multi file editing mode)
	EditAreaLoader.prototype.getFile = function(id, file_id){
		return this.execCommand(id, 'get_file', file_id);
	};
	
	// get all the openned files datas (for multi file editing mode)
	EditAreaLoader.prototype.getAllFiles = function(id){
		return this.execCommand(id, 'get_all_files()');
	};
	
	// open a file (for multi file editing mode)
	EditAreaLoader.prototype.openFile = function(id, file_infos){
		return this.execCommand(id, 'open_file', file_infos);
	};
	
	// close the given file (for multi file editing mode)
	EditAreaLoader.prototype.closeFile = function(id, file_id){
		return this.execCommand(id, 'close_file', file_id);
	};
	
	// close the given file (for multi file editing mode)
	EditAreaLoader.prototype.setFileEditedMode = function(id, file_id, to){
		var reg1= new RegExp('\\\\', 'g');
		var reg2= new RegExp('"', 'g');
		return this.execCommand(id, 'set_file_edited_mode("'+ file_id.replace(reg1, '\\\\').replace(reg2, '\\"') +'", '+ to +')');
	};
	
	
	// allow to access to editarea functions and datas (for advanced users only)
	EditAreaLoader.prototype.execCommand = function(id, cmd, fct_param){
		switch(cmd){
			case "EA_init":
				if(editAreas[id]['settings']["EA_init_callback"].length>0)
					eval(editAreas[id]['settings']["EA_init_callback"]+"('"+ id +"');");
				break;
			case "EA_delete":
				if(editAreas[id]['settings']["EA_delete_callback"].length>0)
					eval(editAreas[id]['settings']["EA_delete_callback"]+"('"+ id +"');");
				break;
			case "EA_submit":
				if(editAreas[id]['settings']["submit_callback"].length>0)
					eval(editAreas[id]['settings']["submit_callback"]+"('"+ id +"');");
				break;
		}
        if(window.frames["frame_"+id] && window.frames["frame_"+ id].editArea){
			if(fct_param!=undefined)
				return eval('window.frames["frame_'+ id +'"].editArea.'+ cmd +'(fct_param);');
			else
				return eval('window.frames["frame_'+ id +'"].editArea.'+ cmd +';');       
        }
        return false;
    };
	
	var editAreaLoader= new EditAreaLoader();
	var editAreas= new Object();
;
include.set_path('resources/edit_area');
function getAttribute(_1,_2){
try{
var _3=_1.getAttribute(_2);
}
catch(exept){
}
if(!_3){
for(var i=0;i<_1.attributes.length;i++){
var _5=_1.attributes[i].name.toLowerCase();
if(_5==_2){
_3=_1.attributes[i].value;
return _3;
}
}
}
return _3;
};
function setAttribute(_6,_7,_8){
if(_7=="class"){
_6.setAttribute("className",_8);
_6.setAttribute("class",_8);
}else{
_6.setAttribute(_7,_8);
}
};
function getChildren(_9,_a,_b,_c,_d,_e){
if(!_d){
var _d="single";
}
if(!_e){
var _e=-1;
}
if(_9){
var _f=_9.childNodes;
var _10=null;
var _11=new Array();
for(var x=0;x<_f.length;x++){
strTagName=new String(_f[x].tagName);
children_class="?";
if(strTagName!="undefined"){
child_attribute=getAttribute(_f[x],_b);
if((strTagName.toLowerCase()==_a.toLowerCase()||_a=="")&&(_b==""||child_attribute==_c)){
if(_d=="all"){
_11.push(_f[x]);
}else{
return _f[x];
}
}
if(_e!=0){
_10=getChildren(_f[x],_a,_b,_c,_d,_e-1);
if(_d=="all"){
if(_10.length>0){
_11=_11.concat(_10);
}
}else{
if(_10!=null){
return _10;
}
}
}
}
}
if(_d=="all"){
return _11;
}
}
return null;
};
function isChildOf(_13,_14){
if(_13){
if(_13==_14){
return true;
}
while(_13.parentNode!="undefined"){
return isChildOf(_13.parentNode,_14);
}
}
return false;
};
function getMouseX(e){
if(e!=null&&typeof (e.pageX)!="undefined"){
return e.pageX;
}else{
return (e!=null?e.x:event.x)+document.documentElement.scrollLeft;
}
};
function getMouseY(e){
if(e!=null&&typeof (e.pageY)!="undefined"){
return e.pageY;
}else{
return (e!=null?e.y:event.y)+document.documentElement.scrollTop;
}
};
function calculeOffsetLeft(r){
return calculeOffset(r,"offsetLeft");
};
function calculeOffsetTop(r){
return calculeOffset(r,"offsetTop");
};
function calculeOffset(_19,_1a){
var _1b=0;
while(_19){
_1b+=_19[_1a];
_19=_19.offsetParent;
}
return _1b;
};
function get_css_property(_1c,_1d){
if(document.defaultView){
return document.defaultView.getComputedStyle(_1c,null).getPropertyValue(_1d);
}else{
if(_1c.currentStyle){
var _1d=_1d.replace(/-\D/gi,function(_1e){
return _1e.charAt(_1e.length-1).toUpperCase();
});
return _1c.currentStyle[_1d];
}else{
return null;
}
}
};
var move_current_element;
function start_move_element(e,id,_21){
var _22=(e.target||e.srcElement).id;
if(id){
_22=id;
}
if(!_21){
_21=window;
}
if(_21.event){
e=_21.event;
}
move_current_element=_21.document.getElementById(_22);
move_current_element.frame=_21;
_21.document.onmousemove=move_element;
_21.document.onmouseup=end_move_element;
mouse_x=getMouseX(e);
mouse_y=getMouseY(e);
move_current_element.start_pos_x=mouse_x-(move_current_element.style.left.replace("px","")||calculeOffsetLeft(move_current_element));
move_current_element.start_pos_y=mouse_y-(move_current_element.style.top.replace("px","")||calculeOffsetTop(move_current_element));
return false;
};
function end_move_element(e){
move_current_element.frame.document.onmousemove="";
move_current_element.frame.document.onmouseup="";
move_current_element=null;
};
function move_element(e){
if(move_current_element.frame&&move_current_element.frame.event){
e=move_current_element.frame.event;
}
var _25=getMouseX(e);
var _26=getMouseY(e);
var _27=_26-move_current_element.start_pos_y;
var _28=_25-move_current_element.start_pos_x;
var _29=move_current_element.frame.document.body.offsetWidth-move_current_element.offsetWidth;
max_top=move_current_element.frame.document.body.offsetHeight-move_current_element.offsetHeight;
_27=Math.min(Math.max(0,_27),max_top);
_28=Math.min(Math.max(0,_28),_29);
move_current_element.style.top=_27+"px";
move_current_element.style.left=_28+"px";
return false;
};
var nav=editAreaLoader.nav;
function getSelectionRange(_2a){
return {"start":_2a.selectionStart,"end":_2a.selectionEnd};
};
function setSelectionRange(_2b,_2c,end){
_2b.focus();
_2c=Math.max(0,Math.min(_2b.value.length,_2c));
end=Math.max(_2c,Math.min(_2b.value.length,end));
if(nav["isOpera"]){
_2b.selectionEnd=1;
_2b.selectionStart=0;
_2b.selectionEnd=1;
_2b.selectionStart=0;
}
_2b.selectionStart=_2c;
_2b.selectionEnd=end;
if(nav["isIE"]){
set_IE_selection(_2b);
}
};
function get_IE_selection(_2e){
if(_2e&&_2e.focused){
if(!_2e.ea_line_height){
var div=document.createElement("div");
div.style.fontFamily=get_css_property(_2e,"font-family");
div.style.fontSize=get_css_property(_2e,"font-size");
div.style.visibility="hidden";
div.innerHTML="0";
document.body.appendChild(div);
_2e.ea_line_height=div.offsetHeight;
document.body.removeChild(div);
}
var _30=document.selection.createRange();
var _31=_30.duplicate();
_31.moveToElementText(_2e);
_31.setEndPoint("EndToEnd",_30);
if(_31.parentElement()==_2e){
var _32=_2e;
var _33=0;
while(_32.parentNode){
_33+=_32.scrollTop;
_32=_32.parentNode;
}
var _34=_30.offsetTop-calculeOffsetTop(_2e)+_33;
var _35=Math.round((_34/_2e.ea_line_height)+1);
var _36=Math.round(_30.boundingHeight/_2e.ea_line_height);
var _37=_31.text.length-_30.text.length;
var tab=_2e.value.substr(0,_37).split("\n");
_37+=(_35-tab.length)*2;
_2e.selectionStart=_37;
var _39=_2e.selectionStart+_30.text.length;
tab=_2e.value.substr(0,_37+_30.text.length).split("\n");
_39+=(_35+_36-1-tab.length)*2;
_2e.selectionEnd=_39;
}
}
setTimeout("get_IE_selection(document.getElementById('"+_2e.id+"'));",50);
};
function IE_textarea_focus(){
event.srcElement.focused=true;
};
function IE_textarea_blur(){
event.srcElement.focused=false;
};
function set_IE_selection(_3a){
if(!window.closed){
var _3b=_3a.value.substr(0,_3a.selectionStart).split("\n").length-1;
var _3c=_3a.value.substr(0,_3a.selectionEnd).split("\n").length-1;
var _3d=document.selection.createRange();
_3d.moveToElementText(_3a);
_3d.setEndPoint("EndToStart",_3d);
_3d.moveStart("character",_3a.selectionStart-_3b);
_3d.moveEnd("character",_3a.selectionEnd-_3c-(_3a.selectionStart-_3b));
_3d.select();
}
};
editAreaLoader.waiting_loading["elements_functions.js"]="loaded";
;
include.set_path('resources/edit_area');
EditAreaLoader.prototype.start_resize_area=function(){
document.onmouseup=editAreaLoader.end_resize_area;
document.onmousemove=editAreaLoader.resize_area;
editAreaLoader.toggle(editAreaLoader.resize["id"]);
var _1=editAreas[editAreaLoader.resize["id"]]["textarea"];
var _2=document.getElementById("edit_area_resize");
if(!_2){
_2=document.createElement("div");
_2.id="edit_area_resize";
_2.style.border="dashed #888888 1px";
}
var _3=_1.offsetWidth-2;
var _4=_1.offsetHeight-2;
_2.style.display="block";
_2.style.width=_3+"px";
_2.style.height=_4+"px";
var _5=_1.parentNode;
_5.insertBefore(_2,_1);
_1.style.display="none";
editAreaLoader.resize["start_top"]=calculeOffsetTop(_2);
editAreaLoader.resize["start_left"]=calculeOffsetLeft(_2);
};
EditAreaLoader.prototype.end_resize_area=function(e){
document.onmouseup="";
document.onmousemove="";
var _7=document.getElementById("edit_area_resize");
var _8=editAreas[editAreaLoader.resize["id"]]["textarea"];
var _9=Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_width"],_7.offsetWidth-4);
var _a=Math.max(editAreas[editAreaLoader.resize["id"]]["settings"]["min_height"],_7.offsetHeight-4);
if(editAreaLoader.nav["isIE"]==6){
_9-=2;
_a-=2;
}
_8.style.width=_9+"px";
_8.style.height=_a+"px";
_7.style.display="none";
_8.style.display="inline";
_8.selectionStart=editAreaLoader.resize["selectionStart"];
_8.selectionEnd=editAreaLoader.resize["selectionEnd"];
editAreaLoader.toggle(editAreaLoader.resize["id"]);
return false;
};
EditAreaLoader.prototype.resize_area=function(e){
var _c=editAreas[editAreaLoader.resize["id"]]["settings"]["allow_resize"];
if(_c=="both"||_c=="y"){
new_y=getMouseY(e);
var _d=Math.max(20,new_y-editAreaLoader.resize["start_top"]);
document.getElementById("edit_area_resize").style.height=_d+"px";
}
if(_c=="both"||_c=="x"){
new_x=getMouseX(e);
var _e=Math.max(20,new_x-editAreaLoader.resize["start_left"]);
document.getElementById("edit_area_resize").style.width=_e+"px";
}
return false;
};
editAreaLoader.waiting_loading["resize_area.js"]="loaded";
;
include.set_path('resources/edit_area');
EditAreaLoader.prototype.get_regexp=function(_1){
res="(\\b)(";
for(i=0;i<_1.length;i++){
if(i>0){
res+="|";
}
res+=this.get_escaped_regexp(_1[i]);
}
res+=")(\\b)";
reg=new RegExp(res);
return res;
};
EditAreaLoader.prototype.get_escaped_regexp=function(_2){
return _2.replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g,"\\$1");
};
EditAreaLoader.prototype.init_syntax_regexp=function(){
var _3=new Object();
for(var _4 in this.load_syntax){
if(!this.syntax[_4]){
this.syntax[_4]=new Object();
this.syntax[_4]["keywords_reg_exp"]=new Object();
this.keywords_reg_exp_nb=0;
if(this.load_syntax[_4]["KEYWORDS"]){
param="g";
if(this.load_syntax[_4]["KEYWORD_CASE_SENSITIVE"]===false){
param+="i";
}
for(var i in this.load_syntax[_4]["KEYWORDS"]){
if(typeof (this.load_syntax[_4]["KEYWORDS"][i])=="function"){
continue;
}
this.syntax[_4]["keywords_reg_exp"][i]=new RegExp(this.get_regexp(this.load_syntax[_4]["KEYWORDS"][i]),param);
this.keywords_reg_exp_nb++;
}
}
if(this.load_syntax[_4]["OPERATORS"]){
var _6="";
var nb=0;
for(var i in this.load_syntax[_4]["OPERATORS"]){
if(typeof (this.load_syntax[_4]["OPERATORS"][i])=="function"){
continue;
}
if(nb>0){
_6+="|";
}
_6+=this.get_escaped_regexp(this.load_syntax[_4]["OPERATORS"][i]);
nb++;
}
if(_6.length>0){
this.syntax[_4]["operators_reg_exp"]=new RegExp("("+_6+")","g");
}
}
if(this.load_syntax[_4]["DELIMITERS"]){
var _6="";
var nb=0;
for(var i in this.load_syntax[_4]["DELIMITERS"]){
if(typeof (this.load_syntax[_4]["DELIMITERS"][i])=="function"){
continue;
}
if(nb>0){
_6+="|";
}
_6+=this.get_escaped_regexp(this.load_syntax[_4]["DELIMITERS"][i]);
nb++;
}
if(_6.length>0){
this.syntax[_4]["delimiters_reg_exp"]=new RegExp("("+_6+")","g");
}
}
var _8=new Array();
this.syntax[_4]["quotes"]=new Object();
var _9=new Array();
if(this.load_syntax[_4]["QUOTEMARKS"]){
for(var i in this.load_syntax[_4]["QUOTEMARKS"]){
if(typeof (this.load_syntax[_4]["QUOTEMARKS"][i])=="function"){
continue;
}
var x=this.get_escaped_regexp(this.load_syntax[_4]["QUOTEMARKS"][i]);
this.syntax[_4]["quotes"][x]=x;
_9[_9.length]="("+x+"(?:[^"+x+"\\\\]*(\\\\\\\\)*(\\\\"+x+"?)?)*("+x+"|$))";
_8.push(x);
}
}
this.syntax[_4]["comments"]=new Object();
if(this.load_syntax[_4]["COMMENT_SINGLE"]){
for(var i in this.load_syntax[_4]["COMMENT_SINGLE"]){
if(typeof (this.load_syntax[_4]["COMMENT_SINGLE"][i])=="function"){
continue;
}
var x=this.get_escaped_regexp(this.load_syntax[_4]["COMMENT_SINGLE"][i]);
_9[_9.length]="("+x+"(.|\\r|\\t)*(\\n|$))";
_8.push(x);
this.syntax[_4]["comments"][x]="\n";
}
}
if(this.load_syntax[_4]["COMMENT_MULTI"]){
for(var i in this.load_syntax[_4]["COMMENT_MULTI"]){
if(typeof (this.load_syntax[_4]["COMMENT_MULTI"][i])=="function"){
continue;
}
var _b=this.get_escaped_regexp(i);
var _c=this.get_escaped_regexp(this.load_syntax[_4]["COMMENT_MULTI"][i]);
_9[_9.length]="("+_b+"(.|\\n|\\r)*?("+_c+"|$))";
_8.push(_b);
_8.push(_c);
this.syntax[_4]["comments"][i]=this.load_syntax[_4]["COMMENT_MULTI"][i];
}
}
if(_9.length>0){
this.syntax[_4]["comment_or_quote_reg_exp"]=new RegExp("("+_9.join("|")+")","gi");
}
if(_8.length>0){
this.syntax[_4]["syntax_trace_regexp"]=new RegExp("((.|\n)*?)(\\\\*("+_8.join("|")+"|$))","gmi");
}
if(this.load_syntax[_4]["SCRIPT_DELIMITERS"]){
this.syntax[_4]["script_delimiters"]=new Object();
for(var i in this.load_syntax[_4]["SCRIPT_DELIMITERS"]){
if(typeof (this.load_syntax[_4]["SCRIPT_DELIMITERS"][i])=="function"){
continue;
}
this.syntax[_4]["script_delimiters"][i]=this.load_syntax[_4]["SCRIPT_DELIMITERS"];
}
}
this.syntax[_4]["custom_regexp"]=new Object();
if(this.load_syntax[_4]["REGEXPS"]){
for(var i in this.load_syntax[_4]["REGEXPS"]){
if(typeof (this.load_syntax[_4]["REGEXPS"][i])=="function"){
continue;
}
var _d=this.load_syntax[_4]["REGEXPS"][i];
if(!this.syntax[_4]["custom_regexp"][_d["execute"]]){
this.syntax[_4]["custom_regexp"][_d["execute"]]=new Object();
}
this.syntax[_4]["custom_regexp"][_d["execute"]][i]={"regexp":new RegExp(_d["search"],_d["modifiers"]),"class":_d["class"]};
}
}
if(this.load_syntax[_4]["STYLES"]){
_3[_4]=new Object();
for(var i in this.load_syntax[_4]["STYLES"]){
if(typeof (this.load_syntax[_4]["STYLES"][i])=="function"){
continue;
}
if(typeof (this.load_syntax[_4]["STYLES"][i])!="string"){
for(var j in this.load_syntax[_4]["STYLES"][i]){
_3[_4][j]=this.load_syntax[_4]["STYLES"][i][j];
}
}else{
_3[_4][i]=this.load_syntax[_4]["STYLES"][i];
}
}
}
var _f="";
for(var i in _3[_4]){
if(_3[_4][i].length>0){
_f+="."+_4+" ."+i.toLowerCase()+" span{"+_3[_4][i]+"}\n";
_f+="."+_4+" ."+i.toLowerCase()+"{"+_3[_4][i]+"}\n";
}
}
this.syntax[_4]["styles"]=_f;
}
}
};
editAreaLoader.waiting_loading["reg_syntax.js"]="loaded";
;
include.set_path('resources');
MVC.JFile=function(_1){
this.path_name=_1;
this.path_array=this.path_name.split("/");
this.last_index=this.path_array.length-1;
};
MVC.JFile.prototype={extension:function(){
var _2=this.file_and_extension();
return (_2.lastIndexOf(".")==-1?null:_2.substring(_2.lastIndexOf(".")+1));
},file_name:function(){
return this.file_and_extension().split(".")[0];
},is_absolute:function(){
return (this.path_name.substring(0,1)=="/"||this.path_name.substring(0,7)=="http://"||this.path_name.substring(0,7)=="file://"||this.path_name.substring(0,8)=="https://");
},file_and_extension:function(){
return this.path_array[this.last_index].split(/[\?#&]/)[0];
},absolute:function(){
return (this.is_absolute()?this.path_name:MVC.JFile.get_cwd()+this.path_name);
},directory:function(){
var _3=this.path_name.split("/");
_3.pop();
return _3.join("/");
}};
MVC.JFile.join=function(){
var _4=[];
for(var i=0;i<arguments.length;i++){
if(arguments[i].replace(/\s+/g,"")!=""){
_4.push(arguments[i].replace(/^\/+/,"").replace(/\/+$/,""));
}
}
return (arguments[0].slice(0,1)=="/"?"/":"")+_4.join("/");
};
MVC.JFile.original_filename=function(_6){
var _7=_6.split("/");
if(_7.length==1){
_7=_6.split("\\");
}
return _7[_7.length-1];
};
MVC.JFile.setup=function(){
var _8;
MVC.JFile.get_cwd=function(){
return _8;
};
MVC.JFile.set_cwd=function(_9){
_8=_9+(_9[_9.length-1]=="/"?"":"/");
};
MVC.JFile.set_cwd(typeof APPLICATION_ROOT=="undefined"?location.href.substring(0,location.href.lastIndexOf("/"))+"/":APPLICATION_ROOT);
};
MVC.JFile.setup();
;
include.set_path('resources');
MVC.JFile.prototype.container=function(){
return (this.directory()==""?MVC.$E("/").next():MVC.$E(this.directory()).next());
};
IDE={};
IDE.clear_selection=function(){
var ds=document.selection;
if(ds&&ds.empty){
ds.empty();
}else{
if(window.getSelection){
var _2=window.getSelection();
if(_2&&_2.collapse){
_2.removeAllRanges();
}
}
}
};
if(document.selection){
Range=function(_3){
this.textRange=_3;
};
Range.prototype.isDocumentSelected=function(){
return this.textRange.offsetLeft==2&&this.textRange.boundingLeft==2;
};
Range.getWindowRange=function(){
return new Range(document.selection.createRange());
};
}else{
Range.getWindowRange=function(){
return window.getSelection().getRangeAt(0);
};
Range.prototype.isDocumentSelected=function(){
var a=1;
return true;
};
}
Container=function(_5,_6){
if(_5){
IDE.recursive_clean(_6,_5);
return _5;
}
var _7=document.createElement("div");
_7.className="container";
_7.style.display="none";
return _7;
};
IDE.recursive_clean=function(_8,_9){
var _a=_8;
if(_a!=""){
_a=_a+"/";
}
var _b=_9.childElements();
for(var i=0;i<_b.length;i++){
var _d=_b[i];
if(_d.id==""){
continue;
}
var f=new MVC.JFile(_d.id);
var _f=_d.id;
_d.id=_a+f.file_and_extension();
if(_d.getAttribute("type")=="directory"){
IDE.recursive_clean(_d.id,_d.next());
}else{
editAreaLoader.getRenameFile("EDITAREA_TEXTAREA",_f,_d.id,f.file_and_extension());
}
}
};
IDE.upload_response=function(_10){
MVC.$E("Upload").hide();
DirectoryView.update(_10);
};
IDE.select=function(_11,_12){
if(IDE.selected&&MVC.$E(IDE.selected)){
MVC.$E(IDE.selected).style.backgroundColor="";
MVC.$E(IDE.selected).style.color="";
}
el=(_12?MVC.$E(_12):MVC.$E(this));
el.style.backgroundColor="rgb(49,106,197)";
el.style.color="White";
IDE.selected=el.id;
return false;
};
(function(){
var _13,_14,_15,_16,_17=0,_18=0;
if(!window.XMLHttpRequest){
_17=-9;
_18=-2;
}
if(window.innerHeight){
getDimensions=function(){
return {width:window.innerWidth,height:window.innerHeight};
};
}else{
getDimensions=function(){
var el=MVC.$E(document.documentElement);
return {width:el.getWidth(),height:el.getHeight()};
};
}
set_height=function(){
var d=getDimensions();
var _1b=d.height,_1c=d.width;
if(!_13){
_13=MVC.$E("frame_EDITAREA_TEXTAREA");
if(!_13){
return;
}
_14=MVC.$E("Upload");
_15=MVC.$E("FILES");
_16=MVC.$E("files_container");
}
var fs=_13.style;
fs.width=(_1c-280)+"px";
fs.height=(_1b-0)+"px";
if(_14.style.display!="none"){
_15.style.height=(_1b-32-250)+"px";
_16.style.height=(_1b-0-250)+"px";
}else{
_15.style.height=(_1b-32+_18)+"px";
_16.style.height=(_1b-0+_18)+"px";
}
_13.style.width=(_1c-251+_17)+"px";
};
})();
function stopPropagation(_1e){
if(!_1e){
_1e=window.event;
}
try{
_1e.cancelBubble=true;
if(_1e.stopPropagation){
_1e.stopPropagation();
}
if(_1e.preventDefault){
_1e.preventDefault();
}
Event.stop(_1e);
}
catch(e){
}
return false;
};
close_upload=function(){
document.getElementById("Upload").style.display="none";
set_height();
};
;
include.set_path('resources');
JITS={};
JITS.getCursorPosition=function(e){
e=e||window.event;
var _2={x:0,y:0};
if(e.pageX||e.pageY){
_2.x=e.pageX;
_2.y=e.pageY;
}else{
var de=document.documentElement;
var b=document.body;
_2.x=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
_2.y=e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
}
return _2;
};
JITS.rightClickMenu={};
JITS.rightClickMenu.setup_init=function(){
if(!MVC.$E("menu")){
var _5=document.createElement("div");
_5.id="menuShadow";
document.body.appendChild(_5);
var _6=document.createElement("div");
_6.id="menu";
document.body.appendChild(_6);
}else{
var _6=MVC.$E("menu");
}
_6.style.position="absolute";
_6.style.display="none";
_5.style.position="absolute";
_5.style.display="none";
JITS.shadow=_5;
JITS.menu=_6;
_6.onmouseover=stopPropagation;
Event.observe(document.body,"click",JITS.rightClickMenu.clear);
document.body.oncontextmenu=JITS.rightClickMenu.clear;
};
JITS.rightClickMenu.timeout=null;
JITS.rightClickMenu.working_element=null;
JITS.rightClickMenu.open=function(_7,_8){
var _9=JITS.getCursorPosition(_8);
var _a=JITS.shadow;
var _b=_a.style;
var _c=JITS.menu;
var _d=_c.style;
_c.innerHTML=_7;
_d.width="200px";
_a.style.width="200px";
var _e=getDimensions();
if(_9.x+300>=_e.width){
_d.left="";
_d.right=(_e.width-_9.x)+"px";
_b.left="";
_b.right=(_e.width-_9.x-2)+"px";
}else{
_d.left=(_9.x+3)+"px";
_b.left=(_9.x+5)+"px";
}
if(_9.y+210>_e.height){
_d.top="";
_b.top="";
_d.bottom=(_e.height-_9.y+5)+"px";
_b.bottom=(_e.height-_9.y+3)+"px";
}else{
_d.top=(_9.y+3)+"px";
_b.top=(_9.y+5)+"px";
_d.bottom="";
_b.bottom="";
}
_d.display="block";
setTimeout(JITS.set_shadow_height,1);
return MVC.$E(_c);
};
JITS.set_shadow_height=function(){
JITS.shadow.style.height=(MVC.$E(JITS.menu).getHeight()-6)+"px";
JITS.shadow.style.display="block";
};
JITS.rightClickMenu.clear=function(){
MVC.$E(JITS.menu).hide();
MVC.$E(JITS.shadow).hide();
};
Event.observe(window,"load",JITS.rightClickMenu.setup_init);
;
include.set_path('resources');
String.prototype.parseColor=function(){
var _1="#";
if(this.slice(0,4)=="rgb("){
var _2=this.slice(4,this.length-1).split(",");
var i=0;
do{
_1+=parseInt(_2[i]).toColorPart();
}while(++i<3);
}else{
if(this.slice(0,1)=="#"){
if(this.length==4){
for(var i=1;i<4;i++){
_1+=(this.charAt(i)+this.charAt(i)).toLowerCase();
}
}
if(this.length==7){
_1=this.toLowerCase();
}
}
}
return (_1.length==7?_1:(arguments[0]||this));
};
Element.collectTextNodes=function(_4){
return $A(MVC.$E(_4).childNodes).collect(function(_5){
return (_5.nodeType==3?_5.nodeValue:(_5.hasChildNodes()?Element.collectTextNodes(_5):""));
}).flatten().join("");
};
Element.collectTextNodesIgnoreClass=function(_6,_7){
return $A(MVC.$E(_6).childNodes).collect(function(_8){
return (_8.nodeType==3?_8.nodeValue:((_8.hasChildNodes()&&!Element.hasClassName(_8,_7))?Element.collectTextNodesIgnoreClass(_8,_7):""));
}).flatten().join("");
};
Element.setContentZoom=function(_9,_a){
_9=MVC.$E(_9);
_9.setStyle({fontSize:(_a/100)+"em"});
if(Prototype.Browser.WebKit){
window.scrollBy(0,0);
}
return _9;
};
Element.getInlineOpacity=function(_b){
return MVC.$E(_b).style.opacity||"";
};
Element.forceRerendering=function(_c){
try{
_c=MVC.$E(_c);
var n=document.createTextNode(" ");
_c.appendChild(n);
_c.removeChild(n);
}
catch(e){
}
};
var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},Transitions:{linear:Prototype.K,sinoidal:function(_e){
return (-Math.cos(_e*Math.PI)/2)+0.5;
},reverse:function(_f){
return 1-_f;
},flicker:function(pos){
var pos=((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4;
return pos>1?1:pos;
},wobble:function(pos){
return (-Math.cos(pos*Math.PI*(9*pos))/2)+0.5;
},pulse:function(pos,_13){
_13=_13||5;
return (((pos%(1/_13))*_13).round()==0?((pos*_13*2)-(pos*_13*2).floor()):1-((pos*_13*2)-(pos*_13*2).floor()));
},spring:function(pos){
return 1-(Math.cos(pos*4.5*Math.PI)*Math.exp(-pos*6));
},none:function(pos){
return 0;
},full:function(pos){
return 1;
}},DefaultOptions:{duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"},tagifyText:function(_17){
var _18="position:relative";
if(Prototype.Browser.IE){
_18+=";zoom:1";
}
_17=MVC.$E(_17);
$A(_17.childNodes).each(function(_19){
if(_19.nodeType==3){
_19.nodeValue.toArray().each(function(_1a){
_17.insertBefore(new Element("span",{style:_18}).update(_1a==" "?String.fromCharCode(160):_1a),_19);
});
Element.remove(_19);
}
});
},multiple:function(_1b,_1c){
var _1d;
if(((typeof _1b=="object")||Object.isFunction(_1b))&&(_1b.length)){
_1d=_1b;
}else{
_1d=MVC.$E(_1b).childNodes;
}
var _1e=Object.extend({speed:0.1,delay:0},arguments[2]||{});
var _1f=_1e.delay;
$A(_1d).each(function(_20,_21){
new _1c(_20,Object.extend(_1e,{delay:_21*_1e.speed+_1f}));
});
},PAIRS:{"slide":["SlideDown","SlideUp"],"blind":["BlindDown","BlindUp"],"appear":["Appear","Fade"]},toggle:function(_22,_23){
_22=MVC.$E(_22);
_23=(_23||"appear").toLowerCase();
var _24=Object.extend({queue:{position:"end",scope:(_22.id||"global"),limit:1}},arguments[2]||{});
Effect[_22.visible()?Effect.PAIRS[_23][1]:Effect.PAIRS[_23][0]](_22,_24);
}};
Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;
Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){
this.effects=[];
this.interval=null;
},_each:function(_25){
this.effects._each(_25);
},add:function(_26){
var _27=new Date().getTime();
var _28=Object.isString(_26.options.queue)?_26.options.queue:_26.options.queue.position;
switch(_28){
case "front":
this.effects.findAll(function(e){
return e.state=="idle";
}).each(function(e){
e.startOn+=_26.finishOn;
e.finishOn+=_26.finishOn;
});
break;
case "with-last":
_27=this.effects.pluck("startOn").max()||_27;
break;
case "end":
_27=this.effects.pluck("finishOn").max()||_27;
break;
}
_26.startOn+=_27;
_26.finishOn+=_27;
if(!_26.options.queue.limit||(this.effects.length<_26.options.queue.limit)){
this.effects.push(_26);
}
if(!this.interval){
this.interval=setInterval(this.loop.bind(this),15);
}
},remove:function(_2b){
this.effects=this.effects.reject(function(e){
return e==_2b;
});
if(this.effects.length==0){
clearInterval(this.interval);
this.interval=null;
}
},loop:function(){
var _2d=new Date().getTime();
for(var i=0,len=this.effects.length;i<len;i++){
this.effects[i]&&this.effects[i].loop(_2d);
}
}});
Effect.Queues={instances:$H(),get:function(_30){
if(!Object.isString(_30)){
return _30;
}
return this.instances.get(_30)||this.instances.set(_30,new Effect.ScopedQueue());
}};
Effect.Queue=Effect.Queues.get("global");
Effect.Base=Class.create({position:null,start:function(_31){
function codeForEvent(_32,_33){
return ((_32[_33+"Internal"]?"this.options."+_33+"Internal(this);":"")+(_32[_33]?"this.options."+_33+"(this);":""));
};
if(_31&&_31.transition===false){
_31.transition=Effect.Transitions.linear;
}
this.options=Object.extend(Object.extend({},Effect.DefaultOptions),_31||{});
this.currentFrame=0;
this.state="idle";
this.startOn=this.options.delay*1000;
this.finishOn=this.startOn+(this.options.duration*1000);
this.fromToDelta=this.options.to-this.options.from;
this.totalTime=this.finishOn-this.startOn;
this.totalFrames=this.options.fps*this.options.duration;
eval("this.render = function(pos){ "+"if (this.state==\"idle\"){this.state=\"running\";"+codeForEvent(this.options,"beforeSetup")+(this.setup?"this.setup();":"")+codeForEvent(this.options,"afterSetup")+"};if (this.state==\"running\"){"+"pos=this.options.transition(pos)*"+this.fromToDelta+"+"+this.options.from+";"+"this.position=pos;"+codeForEvent(this.options,"beforeUpdate")+(this.update?"this.update(pos);":"")+codeForEvent(this.options,"afterUpdate")+"}}");
this.event("beforeStart");
if(!this.options.sync){
Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).add(this);
}
},loop:function(_34){
if(_34>=this.startOn){
if(_34>=this.finishOn){
this.render(1);
this.cancel();
this.event("beforeFinish");
if(this.finish){
this.finish();
}
this.event("afterFinish");
return;
}
var pos=(_34-this.startOn)/this.totalTime,_36=(pos*this.totalFrames).round();
if(_36>this.currentFrame){
this.render(pos);
this.currentFrame=_36;
}
}
},cancel:function(){
if(!this.options.sync){
Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).remove(this);
}
this.state="finished";
},event:function(_37){
if(this.options[_37+"Internal"]){
this.options[_37+"Internal"](this);
}
if(this.options[_37]){
this.options[_37](this);
}
},inspect:function(){
var _38=$H();
for(property in this){
if(!Object.isFunction(this[property])){
_38.set(property,this[property]);
}
}
return "#<Effect:"+_38.inspect()+",options:"+$H(this.options).inspect()+">";
}});
Effect.Parallel=Class.create(Effect.Base,{initialize:function(_39){
this.effects=_39||[];
this.start(arguments[1]);
},update:function(_3a){
this.effects.invoke("render",_3a);
},finish:function(_3b){
this.effects.each(function(_3c){
_3c.render(1);
_3c.cancel();
_3c.event("beforeFinish");
if(_3c.finish){
_3c.finish(_3b);
}
_3c.event("afterFinish");
});
}});
Effect.Tween=Class.create(Effect.Base,{initialize:function(_3d,_3e,to){
_3d=Object.isString(_3d)?MVC.$E(_3d):_3d;
var _40=$A(arguments),_41=_40.last(),_42=_40.length==5?_40[3]:null;
this.method=Object.isFunction(_41)?_41.bind(_3d):Object.isFunction(_3d[_41])?_3d[_41].bind(_3d):function(_43){
_3d[_41]=_43;
};
this.start(Object.extend({from:_3e,to:to},_42||{}));
},update:function(_44){
this.method(_44);
}});
Effect.Event=Class.create(Effect.Base,{initialize:function(){
this.start(Object.extend({duration:0},arguments[0]||{}));
},update:Prototype.emptyFunction});
Effect.Opacity=Class.create(Effect.Base,{initialize:function(_45){
this.element=MVC.$E(_45);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){
this.element.setStyle({zoom:1});
}
var _46=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});
this.start(_46);
},update:function(_47){
this.element.setOpacity(_47);
}});
Effect.Move=Class.create(Effect.Base,{initialize:function(_48){
this.element=MVC.$E(_48);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _49=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});
this.start(_49);
},setup:function(){
this.element.makePositioned();
this.originalLeft=parseFloat(this.element.getStyle("left")||"0");
this.originalTop=parseFloat(this.element.getStyle("top")||"0");
if(this.options.mode=="absolute"){
this.options.x=this.options.x-this.originalLeft;
this.options.y=this.options.y-this.originalTop;
}
},update:function(_4a){
this.element.setStyle({left:(this.options.x*_4a+this.originalLeft).round()+"px",top:(this.options.y*_4a+this.originalTop).round()+"px"});
}});
Effect.MoveBy=function(_4b,_4c,_4d){
return new Effect.Move(_4b,Object.extend({x:_4d,y:_4c},arguments[3]||{}));
};
Effect.Scale=Class.create(Effect.Base,{initialize:function(_4e,_4f){
this.element=MVC.$E(_4e);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _50=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_4f},arguments[2]||{});
this.start(_50);
},setup:function(){
this.restoreAfterFinish=this.options.restoreAfterFinish||false;
this.elementPositioning=this.element.getStyle("position");
this.originalStyle={};
["top","left","width","height","fontSize"].each(function(k){
this.originalStyle[k]=this.element.style[k];
}.bind(this));
this.originalTop=this.element.offsetTop;
this.originalLeft=this.element.offsetLeft;
var _52=this.element.getStyle("font-size")||"100%";
["em","px","%","pt"].each(function(_53){
if(_52.indexOf(_53)>0){
this.fontSize=parseFloat(_52);
this.fontSizeType=_53;
}
}.bind(this));
this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;
this.dims=null;
if(this.options.scaleMode=="box"){
this.dims=[this.element.offsetHeight,this.element.offsetWidth];
}
if(/^content/.test(this.options.scaleMode)){
this.dims=[this.element.scrollHeight,this.element.scrollWidth];
}
if(!this.dims){
this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth];
}
},update:function(_54){
var _55=(this.options.scaleFrom/100)+(this.factor*_54);
if(this.options.scaleContent&&this.fontSize){
this.element.setStyle({fontSize:this.fontSize*_55+this.fontSizeType});
}
this.setDimensions(this.dims[0]*_55,this.dims[1]*_55);
},finish:function(_56){
if(this.restoreAfterFinish){
this.element.setStyle(this.originalStyle);
}
},setDimensions:function(_57,_58){
var d={};
if(this.options.scaleX){
d.width=_58.round()+"px";
}
if(this.options.scaleY){
d.height=_57.round()+"px";
}
if(this.options.scaleFromCenter){
var _5a=(_57-this.dims[0])/2;
var _5b=(_58-this.dims[1])/2;
if(this.elementPositioning=="absolute"){
if(this.options.scaleY){
d.top=this.originalTop-_5a+"px";
}
if(this.options.scaleX){
d.left=this.originalLeft-_5b+"px";
}
}else{
if(this.options.scaleY){
d.top=-_5a+"px";
}
if(this.options.scaleX){
d.left=-_5b+"px";
}
}
}
this.element.setStyle(d);
}});
Effect.Highlight=Class.create(Effect.Base,{initialize:function(_5c){
this.element=MVC.$E(_5c);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _5d=Object.extend({startcolor:"#ffff99"},arguments[1]||{});
this.start(_5d);
},setup:function(){
if(this.element.getStyle("display")=="none"){
this.cancel();
return;
}
this.oldStyle={};
if(!this.options.keepBackgroundImage){
this.oldStyle.backgroundImage=this.element.getStyle("background-image");
this.element.setStyle({backgroundImage:"none"});
}
if(!this.options.endcolor){
this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff");
}
if(!this.options.restorecolor){
this.options.restorecolor=this.element.getStyle("background-color");
}
this._base=$R(0,2).map(function(i){
return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16);
}.bind(this));
this._delta=$R(0,2).map(function(i){
return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i];
}.bind(this));
},update:function(_60){
this.element.setStyle({backgroundColor:$R(0,2).inject("#",function(m,v,i){
return m+((this._base[i]+(this._delta[i]*_60)).round().toColorPart());
}.bind(this))});
},finish:function(){
this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}));
}});
Effect.ScrollTo=function(_64){
var _65=arguments[1]||{},_66=document.viewport.getScrollOffsets(),_67=MVC.$E(_64).cumulativeOffset(),max=(window.height||document.body.scrollHeight)-document.viewport.getHeight();
if(_65.offset){
_67[1]+=_65.offset;
}
return new Effect.Tween(null,_66.top,_67[1]>max?max:_67[1],_65,function(p){
scrollTo(_66.left,p.round());
});
};
Effect.Fade=function(_6a){
_6a=MVC.$E(_6a);
var _6b=_6a.getInlineOpacity();
var _6c=Object.extend({from:_6a.getOpacity()||1,to:0,afterFinishInternal:function(_6d){
if(_6d.options.to!=0){
return;
}
_6d.element.hide().setStyle({opacity:_6b});
}},arguments[1]||{});
return new Effect.Opacity(_6a,_6c);
};
Effect.Appear=function(_6e){
_6e=MVC.$E(_6e);
var _6f=Object.extend({from:(_6e.getStyle("display")=="none"?0:_6e.getOpacity()||0),to:1,afterFinishInternal:function(_70){
_70.element.forceRerendering();
},beforeSetup:function(_71){
_71.element.setOpacity(_71.options.from).show();
}},arguments[1]||{});
return new Effect.Opacity(_6e,_6f);
};
Effect.Puff=function(_72){
_72=MVC.$E(_72);
var _73={opacity:_72.getInlineOpacity(),position:_72.getStyle("position"),top:_72.style.top,left:_72.style.left,width:_72.style.width,height:_72.style.height};
return new Effect.Parallel([new Effect.Scale(_72,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(_72,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(_74){
Position.absolutize(_74.effects[0].element);
},afterFinishInternal:function(_75){
_75.effects[0].element.hide().setStyle(_73);
}},arguments[1]||{}));
};
Effect.BlindUp=function(_76){
_76=MVC.$E(_76);
_76.makeClipping();
return new Effect.Scale(_76,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(_77){
_77.element.hide().undoClipping();
}},arguments[1]||{}));
};
Effect.BlindDown=function(_78){
_78=MVC.$E(_78);
var _79=_78.getDimensions();
return new Effect.Scale(_78,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_79.height,originalWidth:_79.width},restoreAfterFinish:true,afterSetup:function(_7a){
_7a.element.makeClipping().setStyle({height:"0px"}).show();
},afterFinishInternal:function(_7b){
_7b.element.undoClipping();
}},arguments[1]||{}));
};
Effect.SwitchOff=function(_7c){
_7c=MVC.$E(_7c);
var _7d=_7c.getInlineOpacity();
return new Effect.Appear(_7c,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(_7e){
new Effect.Scale(_7e.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(_7f){
_7f.element.makePositioned().makeClipping();
},afterFinishInternal:function(_80){
_80.element.hide().undoClipping().undoPositioned().setStyle({opacity:_7d});
}});
}},arguments[1]||{}));
};
Effect.DropOut=function(_81){
_81=MVC.$E(_81);
var _82={top:_81.getStyle("top"),left:_81.getStyle("left"),opacity:_81.getInlineOpacity()};
return new Effect.Parallel([new Effect.Move(_81,{x:0,y:100,sync:true}),new Effect.Opacity(_81,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(_83){
_83.effects[0].element.makePositioned();
},afterFinishInternal:function(_84){
_84.effects[0].element.hide().undoPositioned().setStyle(_82);
}},arguments[1]||{}));
};
Effect.Shake=function(_85){
_85=MVC.$E(_85);
var _86=Object.extend({distance:20,duration:0.5},arguments[1]||{});
var _87=parseFloat(_86.distance);
var _88=parseFloat(_86.duration)/10;
var _89={top:_85.getStyle("top"),left:_85.getStyle("left")};
return new Effect.Move(_85,{x:_87,y:0,duration:_88,afterFinishInternal:function(_8a){
new Effect.Move(_8a.element,{x:-_87*2,y:0,duration:_88*2,afterFinishInternal:function(_8b){
new Effect.Move(_8b.element,{x:_87*2,y:0,duration:_88*2,afterFinishInternal:function(_8c){
new Effect.Move(_8c.element,{x:-_87*2,y:0,duration:_88*2,afterFinishInternal:function(_8d){
new Effect.Move(_8d.element,{x:_87*2,y:0,duration:_88*2,afterFinishInternal:function(_8e){
new Effect.Move(_8e.element,{x:-_87,y:0,duration:_88,afterFinishInternal:function(_8f){
_8f.element.undoPositioned().setStyle(_89);
}});
}});
}});
}});
}});
}});
};
Effect.SlideDown=function(_90){
_90=MVC.$E(_90).cleanWhitespace();
var _91=_90.down().getStyle("bottom");
var _92=_90.getDimensions();
return new Effect.Scale(_90,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:_92.height,originalWidth:_92.width},restoreAfterFinish:true,afterSetup:function(_93){
_93.element.makePositioned();
_93.element.down().makePositioned();
if(window.opera){
_93.element.setStyle({top:""});
}
_93.element.makeClipping().setStyle({height:"0px"}).show();
},afterUpdateInternal:function(_94){
_94.element.down().setStyle({bottom:(_94.dims[0]-_94.element.clientHeight)+"px"});
},afterFinishInternal:function(_95){
_95.element.undoClipping().undoPositioned();
_95.element.down().undoPositioned().setStyle({bottom:_91});
}},arguments[1]||{}));
};
Effect.SlideUp=function(_96){
_96=MVC.$E(_96).cleanWhitespace();
var _97=_96.down().getStyle("bottom");
var _98=_96.getDimensions();
return new Effect.Scale(_96,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,scaleMode:{originalHeight:_98.height,originalWidth:_98.width},restoreAfterFinish:true,afterSetup:function(_99){
_99.element.makePositioned();
_99.element.down().makePositioned();
if(window.opera){
_99.element.setStyle({top:""});
}
_99.element.makeClipping().show();
},afterUpdateInternal:function(_9a){
_9a.element.down().setStyle({bottom:(_9a.dims[0]-_9a.element.clientHeight)+"px"});
},afterFinishInternal:function(_9b){
_9b.element.hide().undoClipping().undoPositioned();
_9b.element.down().undoPositioned().setStyle({bottom:_97});
}},arguments[1]||{}));
};
Effect.Squish=function(_9c){
return new Effect.Scale(_9c,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(_9d){
_9d.element.makeClipping();
},afterFinishInternal:function(_9e){
_9e.element.hide().undoClipping();
}});
};
Effect.Grow=function(_9f){
_9f=MVC.$E(_9f);
var _a0=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});
var _a1={top:_9f.style.top,left:_9f.style.left,height:_9f.style.height,width:_9f.style.width,opacity:_9f.getInlineOpacity()};
var _a2=_9f.getDimensions();
var _a3,_a4;
var _a5,_a6;
switch(_a0.direction){
case "top-left":
_a3=_a4=_a5=_a6=0;
break;
case "top-right":
_a3=_a2.width;
_a4=_a6=0;
_a5=-_a2.width;
break;
case "bottom-left":
_a3=_a5=0;
_a4=_a2.height;
_a6=-_a2.height;
break;
case "bottom-right":
_a3=_a2.width;
_a4=_a2.height;
_a5=-_a2.width;
_a6=-_a2.height;
break;
case "center":
_a3=_a2.width/2;
_a4=_a2.height/2;
_a5=-_a2.width/2;
_a6=-_a2.height/2;
break;
}
return new Effect.Move(_9f,{x:_a3,y:_a4,duration:0.01,beforeSetup:function(_a7){
_a7.element.hide().makeClipping().makePositioned();
},afterFinishInternal:function(_a8){
new Effect.Parallel([new Effect.Opacity(_a8.element,{sync:true,to:1,from:0,transition:_a0.opacityTransition}),new Effect.Move(_a8.element,{x:_a5,y:_a6,sync:true,transition:_a0.moveTransition}),new Effect.Scale(_a8.element,100,{scaleMode:{originalHeight:_a2.height,originalWidth:_a2.width},sync:true,scaleFrom:window.opera?1:0,transition:_a0.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(_a9){
_a9.effects[0].element.setStyle({height:"0px"}).show();
},afterFinishInternal:function(_aa){
_aa.effects[0].element.undoClipping().undoPositioned().setStyle(_a1);
}},_a0));
}});
};
Effect.Shrink=function(_ab){
_ab=MVC.$E(_ab);
var _ac=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});
var _ad={top:_ab.style.top,left:_ab.style.left,height:_ab.style.height,width:_ab.style.width,opacity:_ab.getInlineOpacity()};
var _ae=_ab.getDimensions();
var _af,_b0;
switch(_ac.direction){
case "top-left":
_af=_b0=0;
break;
case "top-right":
_af=_ae.width;
_b0=0;
break;
case "bottom-left":
_af=0;
_b0=_ae.height;
break;
case "bottom-right":
_af=_ae.width;
_b0=_ae.height;
break;
case "center":
_af=_ae.width/2;
_b0=_ae.height/2;
break;
}
return new Effect.Parallel([new Effect.Opacity(_ab,{sync:true,to:0,from:1,transition:_ac.opacityTransition}),new Effect.Scale(_ab,window.opera?1:0,{sync:true,transition:_ac.scaleTransition,restoreAfterFinish:true}),new Effect.Move(_ab,{x:_af,y:_b0,sync:true,transition:_ac.moveTransition})],Object.extend({beforeStartInternal:function(_b1){
_b1.effects[0].element.makePositioned().makeClipping();
},afterFinishInternal:function(_b2){
_b2.effects[0].element.hide().undoClipping().undoPositioned().setStyle(_ad);
}},_ac));
};
Effect.Pulsate=function(_b3){
_b3=MVC.$E(_b3);
var _b4=arguments[1]||{};
var _b5=_b3.getInlineOpacity();
var _b6=_b4.transition||Effect.Transitions.sinoidal;
var _b7=function(pos){
return _b6(1-Effect.Transitions.pulse(pos,_b4.pulses));
};
_b7.bind(_b6);
return new Effect.Opacity(_b3,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(_b9){
_b9.element.setStyle({opacity:_b5});
}},_b4),{transition:_b7}));
};
Effect.Fold=function(_ba){
_ba=MVC.$E(_ba);
var _bb={top:_ba.style.top,left:_ba.style.left,width:_ba.style.width,height:_ba.style.height};
_ba.makeClipping();
return new Effect.Scale(_ba,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(_bc){
new Effect.Scale(_ba,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(_bd){
_bd.element.hide().undoClipping().setStyle(_bb);
}});
}},arguments[1]||{}));
};
Effect.Morph=Class.create(Effect.Base,{initialize:function(_be){
this.element=MVC.$E(_be);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _bf=Object.extend({style:{}},arguments[1]||{});
if(!Object.isString(_bf.style)){
this.style=$H(_bf.style);
}else{
if(_bf.style.include(":")){
this.style=_bf.style.parseStyle();
}else{
this.element.addClassName(_bf.style);
this.style=$H(this.element.getStyles());
this.element.removeClassName(_bf.style);
var css=this.element.getStyles();
this.style=this.style.reject(function(_c1){
return _c1.value==css[_c1.key];
});
_bf.afterFinishInternal=function(_c2){
_c2.element.addClassName(_c2.options.style);
_c2.transforms.each(function(_c3){
_c2.element.style[_c3.style]="";
});
};
}
}
this.start(_bf);
},setup:function(){
function parseColor(_c4){
if(!_c4||["rgba(0, 0, 0, 0)","transparent"].include(_c4)){
_c4="#ffffff";
}
_c4=_c4.parseColor();
return $R(0,2).map(function(i){
return parseInt(_c4.slice(i*2+1,i*2+3),16);
});
};
this.transforms=this.style.map(function(_c6){
var _c7=_c6[0],_c8=_c6[1],_c9=null;
if(_c8.parseColor("#zzzzzz")!="#zzzzzz"){
_c8=_c8.parseColor();
_c9="color";
}else{
if(_c7=="opacity"){
_c8=parseFloat(_c8);
if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){
this.element.setStyle({zoom:1});
}
}else{
if(Element.CSS_LENGTH.test(_c8)){
var _ca=_c8.match(/^([\+\-]?[0-9\.]+)(.*)$/);
_c8=parseFloat(_ca[1]);
_c9=(_ca.length==3)?_ca[2]:null;
}
}
}
var _cb=this.element.getStyle(_c7);
return {style:_c7.camelize(),originalValue:_c9=="color"?parseColor(_cb):parseFloat(_cb||0),targetValue:_c9=="color"?parseColor(_c8):_c8,unit:_c9};
}.bind(this)).reject(function(_cc){
return ((_cc.originalValue==_cc.targetValue)||(_cc.unit!="color"&&(isNaN(_cc.originalValue)||isNaN(_cc.targetValue))));
});
},update:function(_cd){
var _ce={},_cf,i=this.transforms.length;
while(i--){
_ce[(_cf=this.transforms[i]).style]=_cf.unit=="color"?"#"+(Math.round(_cf.originalValue[0]+(_cf.targetValue[0]-_cf.originalValue[0])*_cd)).toColorPart()+(Math.round(_cf.originalValue[1]+(_cf.targetValue[1]-_cf.originalValue[1])*_cd)).toColorPart()+(Math.round(_cf.originalValue[2]+(_cf.targetValue[2]-_cf.originalValue[2])*_cd)).toColorPart():(_cf.originalValue+(_cf.targetValue-_cf.originalValue)*_cd).toFixed(3)+(_cf.unit===null?"":_cf.unit);
}
this.element.setStyle(_ce,true);
}});
Effect.Transform=Class.create({initialize:function(_d1){
this.tracks=[];
this.options=arguments[1]||{};
this.addTracks(_d1);
},addTracks:function(_d2){
_d2.each(function(_d3){
_d3=$H(_d3);
var _d4=_d3.values().first();
this.tracks.push($H({ids:_d3.keys().first(),effect:Effect.Morph,options:{style:_d4}}));
}.bind(this));
return this;
},play:function(){
return new Effect.Parallel(this.tracks.map(function(_d5){
var ids=_d5.get("ids"),_d7=_d5.get("effect"),_d8=_d5.get("options");
var _d9=[MVC.$E(ids)||$MVC.$E(ids)].flatten();
return _d9.map(function(e){
return new _d7(e,Object.extend({sync:true},_d8));
});
}).flatten(),this.options);
}});
Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle "+"borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth "+"borderRightColor borderRightStyle borderRightWidth borderSpacing "+"borderTopColor borderTopStyle borderTopWidth bottom clip color "+"fontSize fontWeight height left letterSpacing lineHeight "+"marginBottom marginLeft marginRight marginTop markerOffset maxHeight "+"maxWidth minHeight minWidth opacity outlineColor outlineOffset "+"outlineWidth paddingBottom paddingLeft paddingRight paddingTop "+"right textIndent top width wordSpacing zIndex");
Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
String.__parseStyleElement=document.createElement("div");
String.prototype.parseStyle=function(){
var _db,_dc=$H();
if(Prototype.Browser.WebKit){
_db=new Element("div",{style:this}).style;
}else{
String.__parseStyleElement.innerHTML="<div style=\""+this+"\"></div>";
_db=String.__parseStyleElement.childNodes[0].style;
}
Element.CSS_PROPERTIES.each(function(_dd){
if(_db[_dd]){
_dc.set(_dd,_db[_dd]);
}
});
if(Prototype.Browser.IE&&this.include("opacity")){
_dc.set("opacity",this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);
}
return _dc;
};
if(document.defaultView&&document.defaultView.getComputedStyle){
Element.getStyles=function(_de){
var css=document.defaultView.getComputedStyle(MVC.$E(_de),null);
return Element.CSS_PROPERTIES.inject({},function(_e0,_e1){
_e0[_e1]=css[_e1];
return _e0;
});
};
}else{
Element.getStyles=function(_e2){
_e2=MVC.$E(_e2);
var css=_e2.currentStyle,_e4;
_e4=Element.CSS_PROPERTIES.inject({},function(_e5,_e6){
_e5[_e6]=css[_e6];
return _e5;
});
if(!_e4.opacity){
_e4.opacity=_e2.getOpacity();
}
return _e4;
};
}
Effect.Methods={morph:function(_e7,_e8){
_e7=MVC.$E(_e7);
new Effect.Morph(_e7,Object.extend({style:_e8},arguments[2]||{}));
return _e7;
},visualEffect:function(_e9,_ea,_eb){
_e9=MVC.$E(_e9);
var s=_ea.dasherize().camelize(),_ed=s.charAt(0).toUpperCase()+s.substring(1);
new Effect[_ed](_e9,_eb);
return _e9;
},highlight:function(_ee,_ef){
_ee=MVC.$E(_ee);
new Effect.Highlight(_ee,_ef);
return _ee;
}};
$w("fade appear grow shrink fold blindUp blindDown slideUp slideDown "+"pulsate shake puff squish switchOff dropOut").each(function(_f0){
Effect.Methods[_f0]=function(_f1,_f2){
_f1=MVC.$E(_f1);
Effect[_f0.charAt(0).toUpperCase()+_f0.substring(1)](_f1,_f2);
return _f1;
};
});
$w("getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles").each(function(f){
Effect.Methods[f]=Element[f];
});
Element.addMethods(Effect.Methods);
;
include.set_path('resources');
if(Object.isUndefined(Effect)){
throw ("dragdrop.js requires including script.aculo.us' effects.js library");
}
var Droppables={drops:[],remove:function(_1){
this.drops=this.drops.reject(function(d){
return d.element==MVC.$E(_1);
});
},add:function(_3){
_3=MVC.$E(_3);
var _4=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});
if(_4.containment){
_4._containers=[];
var _5=_4.containment;
if(Object.isArray(_5)){
_5.each(function(c){
_4._containers.push(MVC.$E(c));
});
}else{
_4._containers.push(MVC.$E(_5));
}
}
if(_4.accept){
_4.accept=[_4.accept].flatten();
}
Element.makePositioned(_3);
_4.element=_3;
this.drops.push(_4);
},findDeepestChild:function(_7){
deepest=_7[0];
for(i=1;i<_7.length;++i){
if(Element.isParent(_7[i].element,deepest.element)){
deepest=_7[i];
}
}
return deepest;
},isContained:function(_8,_9){
var _a;
if(_9.tree){
_a=_8.treeNode;
}else{
_a=_8.parentNode;
}
return _9._containers.detect(function(c){
return _a==c;
});
},isAffected:function(_c,_d,_e){
return ((_e.element!=_d)&&((!_e._containers)||this.isContained(_d,_e))&&((!_e.accept)||(Element.classNames(_d).detect(function(v){
return _e.accept.include(v);
})))&&Position.withinIncludingScrolloffsets(_e.element,_c[0],_c[1]));
},deactivate:function(_10){
if(_10.hoverclass){
Element.removeClassName(_10.element,_10.hoverclass);
}
this.last_active=null;
},activate:function(_11){
if(_11.hoverclass){
Element.addClassName(_11.element,_11.hoverclass);
}
this.last_active=_11;
},show:function(_12,_13){
if(!this.drops.length){
return;
}
var _14,_15=[];
this.drops.each(function(_16){
if(Droppables.isAffected(_12,_13,_16)){
_15.push(_16);
}
});
if(_15.length>0){
_14=Droppables.findDeepestChild(_15);
}
if(this.last_active&&this.last_active!=_14){
this.deactivate(this.last_active);
}
if(_14){
Position.within(_14.element,_12[0],_12[1]);
if(_14.onHover){
_14.onHover(_13,_14.element,Position.overlap(_14.overlap,_14.element));
}
if(_14!=this.last_active){
Droppables.activate(_14);
}
}
},fire:function(_17,_18){
if(!this.last_active){
return;
}
Position.prepare();
if(this.isAffected([Event.pointerX(_17),Event.pointerY(_17)],_18,this.last_active)){
if(this.last_active.onDrop){
this.last_active.onDrop(_18,this.last_active.element,_17);
return true;
}
}
},reset:function(){
if(this.last_active){
this.deactivate(this.last_active);
}
}};
var Draggables={drags:[],observers:[],register:function(_19){
if(this.drags.length==0){
this.eventMouseUp=this.endDrag.bindAsEventListener(this);
this.eventMouseMove=this.updateDrag.bindAsEventListener(this);
this.eventKeypress=this.keyPress.bindAsEventListener(this);
Event.observe(document,"mouseup",this.eventMouseUp);
Event.observe(document,"mousemove",this.eventMouseMove);
Event.observe(document,"keypress",this.eventKeypress);
}
this.drags.push(_19);
},unregister:function(_1a){
this.drags=this.drags.reject(function(d){
return d==_1a;
});
if(this.drags.length==0){
Event.stopObserving(document,"mouseup",this.eventMouseUp);
Event.stopObserving(document,"mousemove",this.eventMouseMove);
Event.stopObserving(document,"keypress",this.eventKeypress);
}
},activate:function(_1c){
if(_1c.options.delay){
this._timeout=setTimeout(function(){
Draggables._timeout=null;
window.focus();
Draggables.activeDraggable=_1c;
}.bind(this),_1c.options.delay);
}else{
window.focus();
this.activeDraggable=_1c;
}
},deactivate:function(){
this.activeDraggable=null;
},updateDrag:function(_1d){
if(!this.activeDraggable){
return;
}
var _1e=[Event.pointerX(_1d),Event.pointerY(_1d)];
if(this._lastPointer&&(this._lastPointer.inspect()==_1e.inspect())){
return;
}
this._lastPointer=_1e;
this.activeDraggable.updateDrag(_1d,_1e);
},endDrag:function(_1f){
if(this._timeout){
clearTimeout(this._timeout);
this._timeout=null;
}
if(!this.activeDraggable){
return;
}
this._lastPointer=null;
this.activeDraggable.endDrag(_1f);
this.activeDraggable=null;
},keyPress:function(_20){
if(this.activeDraggable){
this.activeDraggable.keyPress(_20);
}
},addObserver:function(_21){
this.observers.push(_21);
this._cacheObserverCallbacks();
},removeObserver:function(_22){
this.observers=this.observers.reject(function(o){
return o.element==_22;
});
this._cacheObserverCallbacks();
},notify:function(_24,_25,_26){
if(this[_24+"Count"]>0){
this.observers.each(function(o){
if(o[_24]){
o[_24](_24,_25,_26);
}
});
}
if(_25.options[_24]){
_25.options[_24](_25,_26);
}
},_cacheObserverCallbacks:function(){
["onStart","onEnd","onDrag"].each(function(_28){
Draggables[_28+"Count"]=Draggables.observers.select(function(o){
return o[_28];
}).length;
});
}};
var Draggable=Class.create({initialize:function(_2a){
var _2b={handle:false,reverteffect:function(_2c,_2d,_2e){
var dur=Math.sqrt(Math.abs(_2d^2)+Math.abs(_2e^2))*0.02;
new Effect.Move(_2c,{x:-_2e,y:-_2d,duration:dur,queue:{scope:"_draggable",position:"end"}});
},endeffect:function(_30){
var _31=Object.isNumber(_30._opacity)?_30._opacity:1;
new Effect.Opacity(_30,{duration:0.2,from:0.7,to:_31,queue:{scope:"_draggable",position:"end"},afterFinish:function(){
Draggable._dragging[_30]=false;
}});
},zindex:1000,revert:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};
if(!arguments[1]||Object.isUndefined(arguments[1].endeffect)){
Object.extend(_2b,{starteffect:function(_32){
_32._opacity=Element.getOpacity(_32);
Draggable._dragging[_32]=true;
new Effect.Opacity(_32,{duration:0.2,from:_32._opacity,to:0.7});
}});
}
var _33=Object.extend(_2b,arguments[1]||{});
this.element=MVC.$E(_2a);
if(_33.handle&&Object.isString(_33.handle)){
this.handle=this.element.down("."+_33.handle,0);
}
if(!this.handle){
this.handle=MVC.$E(_33.handle);
}
if(!this.handle){
this.handle=this.element;
}
if(_33.scroll&&!_33.scroll.scrollTo&&!_33.scroll.outerHTML){
_33.scroll=MVC.$E(_33.scroll);
this._isScrollChild=Element.childOf(this.element,_33.scroll);
}
Element.makePositioned(this.element);
this.options=_33;
this.dragging=false;
this.eventMouseDown=this.initDrag.bindAsEventListener(this);
Event.observe(this.handle,"mousedown",this.eventMouseDown);
Draggables.register(this);
},destroy:function(){
Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);
Draggables.unregister(this);
},currentDelta:function(){
return ([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")]);
},initDrag:function(_34){
if(!Object.isUndefined(Draggable._dragging[this.element])&&Draggable._dragging[this.element]){
return;
}
if(Event.isLeftClick(_34)){
var src=Event.element(_34);
if((tag_name=src.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){
return;
}
var _36=[Event.pointerX(_34),Event.pointerY(_34)];
var pos=Position.cumulativeOffset(this.element);
this.offset=[0,1].map(function(i){
return (_36[i]-pos[i]);
});
Draggables.activate(this);
Event.stop(_34);
}
},startDrag:function(_39){
this.dragging=true;
if(!this.delta){
this.delta=this.currentDelta();
}
if(this.options.zindex){
this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);
this.element.style.zIndex=this.options.zindex;
}
if(this.options.ghosting){
this._clone=this.element.cloneNode(true);
this.element._originallyAbsolute=(this.element.getStyle("position")=="absolute");
if(!this.element._originallyAbsolute){
Position.absolutize(this.element);
}
this.element.parentNode.insertBefore(this._clone,this.element);
}
if(this.options.scroll){
if(this.options.scroll==window){
var _3a=this._getWindowScroll(this.options.scroll);
this.originalScrollLeft=_3a.left;
this.originalScrollTop=_3a.top;
}else{
this.originalScrollLeft=this.options.scroll.scrollLeft;
this.originalScrollTop=this.options.scroll.scrollTop;
}
}
Draggables.notify("onStart",this,_39);
if(this.options.starteffect){
this.options.starteffect(this.element);
}
},updateDrag:function(_3b,_3c){
if(!this.dragging){
this.startDrag(_3b);
}
if(!this.options.quiet){
Position.prepare();
Droppables.show(_3c,this.element);
}
Draggables.notify("onDrag",this,_3b);
this.draw(_3c);
if(this.options.change){
this.options.change(this);
}
if(this.options.scroll){
this.stopScrolling();
var p;
if(this.options.scroll==window){
with(this._getWindowScroll(this.options.scroll)){
p=[left,top,left+width,top+height];
}
}else{
p=Position.page(this.options.scroll);
p[0]+=this.options.scroll.scrollLeft+Position.deltaX;
p[1]+=this.options.scroll.scrollTop+Position.deltaY;
p.push(p[0]+this.options.scroll.offsetWidth);
p.push(p[1]+this.options.scroll.offsetHeight);
}
var _3e=[0,0];
if(_3c[0]<(p[0]+this.options.scrollSensitivity)){
_3e[0]=_3c[0]-(p[0]+this.options.scrollSensitivity);
}
if(_3c[1]<(p[1]+this.options.scrollSensitivity)){
_3e[1]=_3c[1]-(p[1]+this.options.scrollSensitivity);
}
if(_3c[0]>(p[2]-this.options.scrollSensitivity)){
_3e[0]=_3c[0]-(p[2]-this.options.scrollSensitivity);
}
if(_3c[1]>(p[3]-this.options.scrollSensitivity)){
_3e[1]=_3c[1]-(p[3]-this.options.scrollSensitivity);
}
this.startScrolling(_3e);
}
if(Prototype.Browser.WebKit){
window.scrollBy(0,0);
}
Event.stop(_3b);
},finishDrag:function(_3f,_40){
this.dragging=false;
if(this.options.quiet){
Position.prepare();
var _41=[Event.pointerX(_3f),Event.pointerY(_3f)];
Droppables.show(_41,this.element);
}
if(this.options.ghosting){
if(!this.element._originallyAbsolute){
Position.relativize(this.element);
}
delete this.element._originallyAbsolute;
Element.remove(this._clone);
this._clone=null;
}
var _42=false;
if(_40){
_42=Droppables.fire(_3f,this.element);
if(!_42){
_42=false;
}
}
if(_42&&this.options.onDropped){
this.options.onDropped(this.element);
}
Draggables.notify("onEnd",this,_3f);
var _43=this.options.revert;
if(_43&&Object.isFunction(_43)){
_43=_43(this.element);
}
var d=this.currentDelta();
if(_43&&this.options.reverteffect){
if(_42==0||_43!="failure"){
this.options.reverteffect(this.element,d[1]-this.delta[1],d[0]-this.delta[0]);
}
}else{
this.delta=d;
}
if(this.options.zindex){
this.element.style.zIndex=this.originalZ;
}
if(this.options.endeffect){
this.options.endeffect(this.element);
}
Draggables.deactivate(this);
Droppables.reset();
},keyPress:function(_45){
if(_45.keyCode!=Event.KEY_ESC){
return;
}
this.finishDrag(_45,false);
Event.stop(_45);
},endDrag:function(_46){
if(!this.dragging){
return;
}
this.stopScrolling();
this.finishDrag(_46,true);
Event.stop(_46);
},draw:function(_47){
var pos=Position.cumulativeOffset(this.element);
if(this.options.ghosting){
var r=Position.realOffset(this.element);
pos[0]+=r[0]-Position.deltaX;
pos[1]+=r[1]-Position.deltaY;
}
var d=this.currentDelta();
pos[0]-=d[0];
pos[1]-=d[1];
if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){
pos[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;
pos[1]-=this.options.scroll.scrollTop-this.originalScrollTop;
}
var p=[0,1].map(function(i){
return (_47[i]-pos[i]-this.offset[i]);
}.bind(this));
if(this.options.snap){
if(Object.isFunction(this.options.snap)){
p=this.options.snap(p[0],p[1],this);
}else{
if(Object.isArray(this.options.snap)){
p=p.map(function(v,i){
return (v/this.options.snap[i]).round()*this.options.snap[i];
}.bind(this));
}else{
p=p.map(function(v){
return (v/this.options.snap).round()*this.options.snap;
}.bind(this));
}
}
}
var _50=this.element.style;
if((!this.options.constraint)||(this.options.constraint=="horizontal")){
_50.left=p[0]+"px";
}
if((!this.options.constraint)||(this.options.constraint=="vertical")){
_50.top=p[1]+"px";
}
if(_50.visibility=="hidden"){
_50.visibility="";
}
},stopScrolling:function(){
if(this.scrollInterval){
clearInterval(this.scrollInterval);
this.scrollInterval=null;
Draggables._lastScrollPointer=null;
}
},startScrolling:function(_51){
if(!(_51[0]||_51[1])){
return;
}
this.scrollSpeed=[_51[0]*this.options.scrollSpeed,_51[1]*this.options.scrollSpeed];
this.lastScrolled=new Date();
this.scrollInterval=setInterval(this.scroll.bind(this),10);
},scroll:function(){
var _52=new Date();
var _53=_52-this.lastScrolled;
this.lastScrolled=_52;
if(this.options.scroll==window){
with(this._getWindowScroll(this.options.scroll)){
if(this.scrollSpeed[0]||this.scrollSpeed[1]){
var d=_53/1000;
this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1]);
}
}
}else{
this.options.scroll.scrollLeft+=this.scrollSpeed[0]*_53/1000;
this.options.scroll.scrollTop+=this.scrollSpeed[1]*_53/1000;
}
Position.prepare();
Droppables.show(Draggables._lastPointer,this.element);
Draggables.notify("onDrag",this);
if(this._isScrollChild){
Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);
Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*_53/1000;
Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*_53/1000;
if(Draggables._lastScrollPointer[0]<0){
Draggables._lastScrollPointer[0]=0;
}
if(Draggables._lastScrollPointer[1]<0){
Draggables._lastScrollPointer[1]=0;
}
this.draw(Draggables._lastScrollPointer);
}
if(this.options.change){
this.options.change(this);
}
},_getWindowScroll:function(w){
var T,L,W,H;
with(w.document){
if(w.document.documentElement&&documentElement.scrollTop){
T=documentElement.scrollTop;
L=documentElement.scrollLeft;
}else{
if(w.document.body){
T=body.scrollTop;
L=body.scrollLeft;
}
}
if(w.innerWidth){
W=w.innerWidth;
H=w.innerHeight;
}else{
if(w.document.documentElement&&documentElement.clientWidth){
W=documentElement.clientWidth;
H=documentElement.clientHeight;
}else{
W=body.offsetWidth;
H=body.offsetHeight;
}
}
}
return {top:T,left:L,width:W,height:H};
}});
Draggable._dragging={};
var SortableObserver=Class.create({initialize:function(_5a,_5b){
this.element=MVC.$E(_5a);
this.observer=_5b;
this.lastValue=Sortable.serialize(this.element);
},onStart:function(){
this.lastValue=Sortable.serialize(this.element);
},onEnd:function(){
Sortable.unmark();
if(this.lastValue!=Sortable.serialize(this.element)){
this.observer(this.element);
}
}});
var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(_5c){
while(_5c.tagName.toUpperCase()!="BODY"){
if(_5c.id&&Sortable.sortables[_5c.id]){
return _5c;
}
_5c=_5c.parentNode;
}
},options:function(_5d){
_5d=Sortable._findRootElement(MVC.$E(_5d));
if(!_5d){
return;
}
return Sortable.sortables[_5d.id];
},destroy:function(_5e){
var s=Sortable.options(_5e);
if(s){
Draggables.removeObserver(s.element);
s.droppables.each(function(d){
Droppables.remove(d);
});
s.draggables.invoke("destroy");
delete Sortable.sortables[s.element.id];
}
},create:function(_61){
_61=MVC.$E(_61);
var _62=Object.extend({element:_61,tag:"li",dropOnEmpty:false,tree:false,treeTag:"ul",overlap:"vertical",constraint:"vertical",containment:_61,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,elements:false,handles:false,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});
this.destroy(_61);
var _63={revert:true,quiet:_62.quiet,scroll:_62.scroll,scrollSpeed:_62.scrollSpeed,scrollSensitivity:_62.scrollSensitivity,delay:_62.delay,ghosting:_62.ghosting,constraint:_62.constraint,handle:_62.handle};
if(_62.starteffect){
_63.starteffect=_62.starteffect;
}
if(_62.reverteffect){
_63.reverteffect=_62.reverteffect;
}else{
if(_62.ghosting){
_63.reverteffect=function(_64){
_64.style.top=0;
_64.style.left=0;
};
}
}
if(_62.endeffect){
_63.endeffect=_62.endeffect;
}
if(_62.zindex){
_63.zindex=_62.zindex;
}
var _65={overlap:_62.overlap,containment:_62.containment,tree:_62.tree,hoverclass:_62.hoverclass,onHover:Sortable.onHover};
var _66={onHover:Sortable.onEmptyHover,overlap:_62.overlap,containment:_62.containment,hoverclass:_62.hoverclass};
Element.cleanWhitespace(_61);
_62.draggables=[];
_62.droppables=[];
if(_62.dropOnEmpty||_62.tree){
Droppables.add(_61,_66);
_62.droppables.push(_61);
}
(_62.elements||this.findElements(_61,_62)||[]).each(function(e,i){
var _69=_62.handles?MVC.$E(_62.handles[i]):(_62.handle?MVC.$E(e).select("."+_62.handle)[0]:e);
_62.draggables.push(new Draggable(e,Object.extend(_63,{handle:_69})));
Droppables.add(e,_65);
if(_62.tree){
e.treeNode=_61;
}
_62.droppables.push(e);
});
if(_62.tree){
(Sortable.findTreeElements(_61,_62)||[]).each(function(e){
Droppables.add(e,_66);
e.treeNode=_61;
_62.droppables.push(e);
});
}
this.sortables[_61.id]=_62;
Draggables.addObserver(new SortableObserver(_61,_62.onUpdate));
},findElements:function(_6b,_6c){
return Element.findChildren(_6b,_6c.only,_6c.tree?true:false,_6c.tag);
},findTreeElements:function(_6d,_6e){
return Element.findChildren(_6d,_6e.only,_6e.tree?true:false,_6e.treeTag);
},onHover:function(_6f,_70,_71){
if(Element.isParent(_70,_6f)){
return;
}
if(_71>0.33&&_71<0.66&&Sortable.options(_70).tree){
return;
}else{
if(_71>0.5){
Sortable.mark(_70,"before");
if(_70.previousSibling!=_6f){
var _72=_6f.parentNode;
_6f.style.visibility="hidden";
_70.parentNode.insertBefore(_6f,_70);
if(_70.parentNode!=_72){
Sortable.options(_72).onChange(_6f);
}
Sortable.options(_70.parentNode).onChange(_6f);
}
}else{
Sortable.mark(_70,"after");
var _73=_70.nextSibling||null;
if(_73!=_6f){
var _72=_6f.parentNode;
_6f.style.visibility="hidden";
_70.parentNode.insertBefore(_6f,_73);
if(_70.parentNode!=_72){
Sortable.options(_72).onChange(_6f);
}
Sortable.options(_70.parentNode).onChange(_6f);
}
}
}
},onEmptyHover:function(_74,_75,_76){
var _77=_74.parentNode;
var _78=Sortable.options(_75);
if(!Element.isParent(_75,_74)){
var _79;
var _7a=Sortable.findElements(_75,{tag:_78.tag,only:_78.only});
var _7b=null;
if(_7a){
var _7c=Element.offsetSize(_75,_78.overlap)*(1-_76);
for(_79=0;_79<_7a.length;_79+=1){
if(_7c-Element.offsetSize(_7a[_79],_78.overlap)>=0){
_7c-=Element.offsetSize(_7a[_79],_78.overlap);
}else{
if(_7c-(Element.offsetSize(_7a[_79],_78.overlap)/2)>=0){
_7b=_79+1<_7a.length?_7a[_79+1]:null;
break;
}else{
_7b=_7a[_79];
break;
}
}
}
}
_75.insertBefore(_74,_7b);
Sortable.options(_77).onChange(_74);
_78.onChange(_74);
}
},unmark:function(){
if(Sortable._marker){
Sortable._marker.hide();
}
},mark:function(_7d,_7e){
var _7f=Sortable.options(_7d.parentNode);
if(_7f&&!_7f.ghosting){
return;
}
if(!Sortable._marker){
Sortable._marker=(MVC.$E("dropmarker")||Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({position:"absolute"});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
}
var _80=Position.cumulativeOffset(_7d);
Sortable._marker.setStyle({left:_80[0]+"px",top:_80[1]+"px"});
if(_7e=="after"){
if(_7f.overlap=="horizontal"){
Sortable._marker.setStyle({left:(_80[0]+_7d.clientWidth)+"px"});
}else{
Sortable._marker.setStyle({top:(_80[1]+_7d.clientHeight)+"px"});
}
}
Sortable._marker.show();
},_tree:function(_81,_82,_83){
var _84=Sortable.findElements(_81,_82)||[];
for(var i=0;i<_84.length;++i){
var _86=_84[i].id.match(_82.format);
if(!_86){
continue;
}
var _87={id:encodeURIComponent(_86?_86[1]:null),element:_81,parent:_83,children:[],position:_83.children.length,container:MVC.$E(_84[i]).down(_82.treeTag)};
if(_87.container){
this._tree(_87.container,_82,_87);
}
_83.children.push(_87);
}
return _83;
},tree:function(_88){
_88=MVC.$E(_88);
var _89=this.options(_88);
var _8a=Object.extend({tag:_89.tag,treeTag:_89.treeTag,only:_89.only,name:_88.id,format:_89.format},arguments[1]||{});
var _8b={id:null,parent:null,children:[],container:_88,position:0};
return Sortable._tree(_88,_8a,_8b);
},_constructIndex:function(_8c){
var _8d="";
do{
if(_8c.id){
_8d="["+_8c.position+"]"+_8d;
}
}while((_8c=_8c.parent)!=null);
return _8d;
},sequence:function(_8e){
_8e=MVC.$E(_8e);
var _8f=Object.extend(this.options(_8e),arguments[1]||{});
return MVC.$E(this.findElements(_8e,_8f)||[]).map(function(_90){
return _90.id.match(_8f.format)?_90.id.match(_8f.format)[1]:"";
});
},setSequence:function(_91,_92){
_91=MVC.$E(_91);
var _93=Object.extend(this.options(_91),arguments[2]||{});
var _94={};
this.findElements(_91,_93).each(function(n){
if(n.id.match(_93.format)){
_94[n.id.match(_93.format)[1]]=[n,n.parentNode];
}
n.parentNode.removeChild(n);
});
_92.each(function(_96){
var n=_94[_96];
if(n){
n[1].appendChild(n[0]);
delete _94[_96];
}
});
},serialize:function(_98){
_98=MVC.$E(_98);
var _99=Object.extend(Sortable.options(_98),arguments[1]||{});
var _9a=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:_98.id);
if(_99.tree){
return Sortable.tree(_98,arguments[1]).children.map(function(_9b){
return [_9a+Sortable._constructIndex(_9b)+"[id]="+encodeURIComponent(_9b.id)].concat(_9b.children.map(arguments.callee));
}).flatten().join("&");
}else{
return Sortable.sequence(_98,arguments[1]).map(function(_9c){
return _9a+"[]="+encodeURIComponent(_9c);
}).join("&");
}
}};
Element.isParent=function(_9d,_9e){
if(!_9d.parentNode||_9d==_9e){
return false;
}
if(_9d.parentNode==_9e){
return true;
}
return Element.isParent(_9d.parentNode,_9e);
};
Element.findChildren=function(_9f,_a0,_a1,_a2){
if(!_9f.hasChildNodes()){
return null;
}
_a2=_a2.toUpperCase();
if(_a0){
_a0=[_a0].flatten();
}
var _a3=[];
$A(_9f.childNodes).each(function(e){
if(e.tagName&&e.tagName.toUpperCase()==_a2&&(!_a0||(Element.classNames(e).detect(function(v){
return _a0.include(v);
})))){
_a3.push(e);
}
if(_a1){
var _a6=Element.findChildren(e,_a0,_a1,_a2);
if(_a6){
_a3.push(_a6);
}
}
});
return (_a3.length>0?_a3.flatten():[]);
};
Element.offsetSize=function(_a7,_a8){
return _a7["offset"+((_a8=="vertical"||_a8=="height")?"Height":"Width")];
};
;
include.set_path('resources');
var Swiff=function(_1,_2){
if(!Swiff.fixed){
Swiff.fix();
}
var _3=Swiff.nextInstance();
Swiff.vars[_3]={};
_2=$merge({width:100,height:100,id:_3,wmode:"transparent",bgcolor:"#ffffff",allowScriptAccess:"sameDomain",callBacks:{"onLoad":Class.empty},params:false},_2||{});
var _4=[];
for(var p in _2.callBacks){
Swiff.vars[_3][p]=_2.callBacks[p];
_4.push(p+"=Swiff.vars."+_3+"."+p);
}
if(_2.params){
_4.push(Object.toQueryString(_2.params));
}
var _6=_1+"?"+_4.join("&");
var _7=document.createElement("div");
_7.innerHTML=["<object width=\"",_2.width,"\" height=\"",_2.height,"\" id=\"",_2.id,"\" type=\"application/x-shockwave-flash\" data=\"",_6,"\">","<param name=\"allowScriptAccess\" value=\"",_2.allowScriptAccess,"\" />","<param name=\"movie\" value=\"",_6,"\" />","<param name=\"bgcolor\" value=\"",_2.bgcolor,"\" />","<param name=\"scale\" value=\"noscale\" />","<param name=\"salign\" value=\"lt\" />","<param name=\"wmode\" value=\"",_2.wmode,"\" />","</object>"].join("");
return _7.firstChild;
};
MVC.Object.extend(Swiff,{count:0,callBacks:{},vars:{},nextInstance:function(){
return "Swiff"+Swiff.count++;
},fix:function(){
Swiff.fixed=true;
MVC.Event.observe(window,"unload",function(){
__flash_unloadHandler=__flash_savedUnloadHandler=function(){
};
});
if(!window.ie){
return;
}
MVC.Event.observe(window,"unload",function(){
var _8=document.getElementsByTagName("object");
for(var o=0;o<_8.length;o++){
_8[o].style.display="none";
for(var p in _8[o]){
if(typeof _8[o][p]=="function"){
_8[o][p]=function(){
};
}
}
}
});
},getVersion:function(){
if(!Swiff.pluginVersion){
var x;
if(navigator.plugins&&navigator.mimeTypes.length){
x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){
x=x.description;
}
}else{
if(window.ie){
try{
x=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
x=x.GetVariable("$version");
}
catch(e){
}
}
}
Swiff.pluginVersion=(typeof x=="string")?parseInt(x.match(/\d+/)[0]):0;
}
return Swiff.pluginVersion;
},remote:function(_c,fn){
var rs=_c.CallFunction("<invoke name=\""+fn+"\" returntype=\"javascript\">"+__flash__argumentsToXML(arguments,2)+"</invoke>");
return eval(rs);
}});
;
include.set_path('resources');
function $merge(){
var _1={};
for(var i=0;i<arguments.length;i++){
for(var _3 in arguments[i]){
var ap=arguments[i][_3];
var mp=_1[_3];
if(mp&&typeof ap=="object"&&typeof mp=="object"){
_1[_3]=$merge(mp,ap);
}else{
_1[_3]=ap;
}
}
}
return _1;
};
Swiff.Uploader=MVC.Class.extend({options:{types:false,multiple:true,queued:true,swf:null,url:null,container:null},callBacks:{onOpen:Class.empty,onProgress:Class.empty,onSelect:Class.empty,onComplete:Class.empty,onError:Class.empty,onCancel:Class.empty},init:function(_6,_7,_8){
if(Swiff.getVersion()<8){
return false;
}
MVC.Object.extend(this.options,_8);
this.onLoaded=_7;
var _9=MVC.Object.extend($merge(this.callBacks),_6||{});
for(p in _9){
_9[p]=MVC.Function.bind(_9[p],this);
}
this.instance=Swiff.nextInstance();
Swiff.callBacks[this.instance]=_9;
this.object=Swiff.Uploader.register(MVC.Function.bind(this.loaded,this),this.options.swf,this.options.container);
return this;
},loaded:function(){
Swiff.remote(this.object,"create",this.instance,this.options.types,this.options.multiple,this.options.queued,this.options.url);
setTimeout(this.onLoaded,10);
},browse:function(){
Swiff.remote(this.object,"browse",this.instance);
},send:function(_a){
Swiff.remote(this.object,"upload",this.instance,_a);
},remove:function(_b,_c){
Swiff.remote(this.object,"remove",this.instance,_b,_c);
},fileIndex:function(_d,_e){
return Swiff.remote(this.object,"fileIndex",this.instance,_d,_e);
},fileList:function(){
return Swiff.remote(this.object,"filelist",this.instance);
}});
MVC.Object.extend(Swiff.Uploader,{swf:"Swiff.Uploader.swf",callBacks:[],register:function(_f,url,_11){
if(!Swiff.Uploader.object||!Swiff.Uploader.loaded){
Swiff.Uploader.callBacks.push(_f);
if(!Swiff.Uploader.object){
Swiff.Uploader.object=new Swiff(url||Swiff.Uploader.swf,{callBacks:{"onLoad":Swiff.Uploader.onLoad}});
(_11||document.body).appendChild(Swiff.Uploader.object);
}
}else{
_f.delay(10);
}
return Swiff.Uploader.object;
},onLoad:function(){
Swiff.Uploader.loaded=true;
for(var c=0;c<Swiff.Uploader.callBacks.length;c++){
setTimeout(Swiff.Uploader.callBacks[c],10);
}
Swiff.Uploader.callBacks.length=0;
}});
;
include.set_path('resources');
FancyUpload=MVC.Class.extend({options:{url:false,swf:"Swiff.Uploader.swf",multiple:true,queued:true,types:{"Images (*.jpg, *.jpeg, *.gif, *.png)":"*.jpg; *.jpeg; *.gif; *.png"},limitSize:false,limitFiles:false,createReplacement:null,instantStart:false,allowDuplicates:false,optionFxDuration:250,container:null,queueList:"photoupload-queue",onComplete:function(){
},onError:function(){
},onCancel:function(){
},onAllComplete:function(){
}},init:function(el,_2){
this.element=MVC.$E(el);
MVC.Object.extend(this.options,_2);
this.options.url=this.options.url||this.element.form.action||location.href;
this.fileList=[];
this.uploader=new Swiff.Uploader({onOpen:MVC.Function.bind(this.onOpen,this),onProgress:MVC.Function.bind(this.onProgress,this),onComplete:MVC.Function.bind(this.onComplete,this),onError:MVC.Function.bind(this.onError,this),onSelect:MVC.Function.bind(this.onSelect,this)},MVC.Function.bind(this.initializeFlash,this),{swf:this.options.swf,types:this.options.types,multiple:this.options.multiple,queued:this.options.queued,container:this.options.container});
},set_url:function(_3){
this.options.url="/upload?_ftp_session_id="+readCookie("_ftp_session_id")+"&path="+_3;
},initializeFlash:function(){
this.queue=MVC.$E(this.options.queueList);
MVC.Event.observe(MVC.$E(this.element.form),"submit",MVC.Function.bind(this.upload,this));
if(this.options.createReplacement){
this.options.createReplacement(this.element);
}else{
var _4=document.createElement("input");
_4.type="button";
_4.value="Browse Files";
this.element.parentNode.insertBefore(_4,this.element);
MVC.Event.observe(_4,"click",MVC.Function.bind(this.browse,this));
this.element.parentNode.removeChild(this.element);
}
},browse:function(){
this.uploader.browse();
},upload:function(e){
if(!e){
e=window.event;
}
try{
e.cancelBubble=true;
if(e.stopPropagation){
e.stopPropagation();
}
if(e.preventDefault){
e.preventDefault();
}
}
catch(e){
}
this.uploader.send(this.options.url);
},onSelect:function(_6,_7){
if(this.uploadTimer){
this.uploadTimer=$clear(this.uploadTimer);
}
if((this.options.limitSize&&(_7>this.options.limitSize))||(this.options.limitFiles&&(this.fileList.length>=this.options.limitFiles))||(!this.options.allowDuplicates&&this.findFile(_6,_7)!=-1)){
return false;
}
this.addFile(_6,_7);
if(this.options.instantStart){
this.uploadTimer=this.upload.delay(250,this);
}
return true;
},onOpen:function(_8,_9){
var _a=this.findFile(_8,_9);
this.fileList[_a].status=1;
if(this.fileList[_a].fx){
return;
}
this.fileList[_a].fx=new Element("div",{"class":"queue-subloader"}).injectInside(new Element("div",{"class":"queue-loader"}).setHTML("Uploading").injectInside(this.fileList[_a].element)).effect("width",{duration:200,wait:false,unit:"%",transition:Fx.Transitions.linear}).set(0);
if(MVC.$E("clear_completed").innerHTML==""){
MVC.$E("clear_completed").adopt(new Element("a",{href:"javascript:void(null);",events:{click:this.clearList.bind(this,[false])}}).setHTML("Clear Completed"));
}
},onProgress:function(_b,_c,_d,_e){
},onComplete:function(_f,_10){
var _11=this.uploadStatus(_f,_10,100);
this.fileList[_11].status=2;
this.checkComplete(_f,_10,"onComplete");
},onError:function(_12,_13,_14){
var msg="Upload failed ("+_14+")";
switch(_14.toInt()){
case 500:
msg="Internal server error, please contact Administrator!";
break;
case 400:
msg="Upload failed, please check your filesize!";
break;
case 409:
msg="Could not process image, please choose another!";
break;
case 415:
msg="Unsupported media type, please upload GIF, PNG, TIFF or JPEG!";
break;
case 412:
msg="Invalid target, please reload page and try again!";
break;
case 417:
msg="Photo too small, please keep our photo manifest in mind!";
break;
}
var _16=this.uploadStatus(_12,_13,100);
this.fileList[_16].fx.element.setStyle("background-color","#ffd780").setHTML(msg);
this.fileList[_16].status=2;
this.highlight(_16,"ffd780");
this.checkComplete(_12,_13,"onError");
},checkComplete:function(_17,_18,_19){
this.options[_19](_17,_18);
if(this.nextFile()==-1){
this.options.onAllComplete();
}
},addFile:function(_1a,_1b){
if(!this.options.multiple&&this.fileList.length){
this.remove(this.fileList[0].name,this.fileList[0].size);
}
var li=document.createElement("li");
li.innerHTML="<span class=\"queue-file\">"+_1a+"</span><span class=\"queue-size\" title=\""+_1b+" byte\">~"+Math.ceil(_1b/1000)+" kb</span>";
this.queue.appendChild(li);
this.fileList.push({name:_1a,size:_1b,status:0,percentage:0,element:li});
var a=document.createElement("a");
a.href="javascript:void(0)";
a.className="input-delete";
a.setAttribute("title","Remove from queue");
a.data={name:_1a,size:_1b};
li.insertBefore(a,li.firstChild);
MVC.Event.observe(a,"click",MVC.Function.bind(this.cancelFile,this));
},uploadStatus:function(_1e,_1f,_20){
var _21=this.findFile(_1e,_1f);
this.fileList[_21].percentage=_20;
return _21;
},uploadOverview:function(){
var l=this.fileList.length,i=-1,_24=0;
while(++i<l){
_24+=this.fileList[i].percentage;
}
return Math.ceil(_24/l);
},highlight:function(_25,_26){
return this.fileList[_25].element.effect("background-color",{duration:this.options.optionFxDuration}).start(_26,"fff");
},cancelFile:function(e,_28,_29){
this.remove(e.target.data.name,e.target.data.size);
},remove:function(_2a,_2b,_2c){
if(_2a){
_2c=this.findFile(_2a,_2b);
}
if(_2c==-1){
return;
}
if(this.fileList[_2c].status<2){
this.uploader.remove(_2a,_2b);
this.checkComplete(_2a,_2b,"onCancel");
}
this.fileList[_2c].element.parentNode.removeChild(this.fileList[_2c].element);
this.fileList.splice(_2c,1);
return;
},findFile:function(_2d,_2e){
var l=this.fileList.length,i=-1;
while(++i<l){
if(this.fileList[i].name==_2d&&this.fileList[i].size==_2e){
return i;
}
}
return -1;
},nextFile:function(){
var l=this.fileList.length,i=-1;
while(++i<l){
if(this.fileList[i].status!=2){
return i;
}
}
return -1;
},clearList:function(_33){
var i=-1;
while(++i<this.fileList.length){
if(_33||this.fileList[i].status==2){
this.remove(0,0,0,i--);
}
}
},fireEvent:function(_35,_36,_37){
if(this.$events&&this.$events[_35]){
this.$events[_35].each(function(fn){
fn.create({"bind":this,"delay":_37,"arguments":_36})();
},this);
}
return this;
}});
;
include.set_path('resources');
editAreaLoader.init({id:"EDITAREA_TEXTAREA",syntax:"js",start_highlight:true,allow_resize:"no",allow_toggle:false,save_callback:"File.save",EA_load_callback:"set_height",EA_file_close_callback:"File.close",toolbar:"save, search, go_to_line, fullscreen, undo, redo,  select_font, change_smooth_selection, highlight, reset_highlight, syntax_selection",is_multi_files:true,syntax_selection_allow:"c,cpp,python,xml,js,jst,html,css,php"});
;
include.set_path('resources/edit_area/langs');
editAreaLoader.lang["en"]={new_document:"new empty document",search_button:"search and replace",search_command:"search next / open search area",search:"search",replace:"replace",replace_command:"replace / open search area",find_next:"find next",replace_all:"replace all",reg_exp:"regular expressions",match_case:"match case",not_found:"not found.",occurrence_replaced:"occurences replaced.",search_field_empty:"Search field empty",restart_search_at_begin:"End of area reached. Restart at begin.",move_popup:"move search popup",font_size:"--Font size--",go_to_line:"go to line",go_to_line_prompt:"go to line number:",undo:"undo",redo:"redo",change_smooth_selection:"enable/disable some display features (smarter display but more CPU charge)",highlight:"toggle syntax highlight on/off",reset_highlight:"reset highlight (if desyncronized from text)",help:"about",save:"save",load:"load",line_abbr:"Ln",char_abbr:"Ch",position:"Position",total:"Total",close_popup:"close popup",shortcuts:"Shortcuts",add_tab:"add tabulation to text",remove_tab:"remove tabulation to text",about_notice:"Notice: syntax highlight function is only for small text",toggle:"Toggle editor",accesskey:"Accesskey",tab:"Tab",shift:"Shift",ctrl:"Ctrl",esc:"Esc",processing:"Processing...",fullscreen:"fullscreen",syntax_selection:"--Syntax--",syntax_css:"CSS",syntax_html:"HTML",syntax_js:"Javascript",syntax_php:"Php",syntax_python:"Python",syntax_vb:"Visual Basic",syntax_xml:"Xml",syntax_c:"C",syntax_cpp:"CPP",syntax_basic:"Basic",syntax_pas:"Pascal",syntax_brainfuck:"Brainfuck",syntax_sql:"SQL",close_tab:"Close file"};
;
include.set_path('resources/edit_area/reg_syntax');
editAreaLoader.load_syntax["js"]={"COMMENT_SINGLE":{1:"//"},"COMMENT_MULTI":{"/*":"*/"},"QUOTEMARKS":{1:"'",2:"\""},"KEYWORD_CASE_SENSITIVE":false,"KEYWORDS":{"statements":["as","break","case","catch","continue","decodeURI","delete","do","else","encodeURI","eval","finally","for","if","in","is","item","instanceof","return","switch","this","throw","try","typeof","void","while","write","with"],"keywords":["class","const","default","debugger","export","extends","false","function","import","namespace","new","null","package","private","protected","public","super","true","use","var","window","document","Link ","outerHeight ","Anchor","FileUpload","location","outerWidth","Select","Area","find","Location","Packages","self","arguments","locationbar","pageXoffset","Form","Math","pageYoffset","setTimeout","assign","Frame","menubar","parent","status","blur","frames","MimeType","parseFloat","statusbar","Boolean","Function","moveBy","parseInt","stop","Button","getClass","moveTo","Password","String","callee","Hidden","name","personalbar","Submit","caller","history","NaN","Plugin","sun","captureEvents","History","navigate","print","taint","Checkbox","home","navigator","prompt","Text","Image","Navigator","prototype","Textarea","clearTimeout","Infinity","netscape","Radio","toolbar","close","innerHeight","Number","ref","top","closed","innerWidth","Object","RegExp","toString","confirm","isFinite","onBlur","releaseEvents","unescape","constructor","isNan","onError","Reset","untaint","Date","java","onFocus","resizeBy","unwatch","defaultStatus","JavaArray","onLoad","resizeTo","valueOf","document","JavaClass","onUnload","routeEvent","watch","Document","JavaObject","open","scroll","window","Element","JavaPackage","opener","scrollbars","Window","escape","length","Option","scrollBy"],"functions":["alert","Array","back","blur","clearInterval","close","confirm","eval ","focus","forward","home","name","navigate","onblur","onerror","onfocus","onload","onmove","onresize","onunload","open","print","prompt","scroll","scrollTo","setInterval","status","stop"]},"OPERATORS":["+","-","/","*","=","<",">","%","!"],"DELIMITERS":["(",")","[","]","{","}"],"STYLES":{"COMMENTS":"color: #AAAAAA;","QUOTESMARKS":"color: #6381F8;","KEYWORDS":{"statements":"color: #60CA00;","keywords":"color: #48BDDF;","functions":"color: #2B60FF;"},"OPERATORS":"color: #FF00FF;","DELIMITERS":"color: #0038E1;"}};
;
include.next_function();
include.set_path('models');
FileData=function(_1){
var f=new MVC.JFile(_1.id);
this.name=f.file_and_extension();
this.type=_1.getAttribute("type");
this.path=_1.id;
};
File={};
File.sort=function(_3,_4){
if(_3.type>_4.type){
return 1;
}
if(_3.type<_4.type){
return -1;
}
var _5=_3.name.toLowerCase(),_6=_4.name.toLowerCase();
if(_5>_6){
return 1;
}
return _5.toLowerCase()<_6.toLowerCase()?-1:0;
};
File.close=function(){
};
File.save=function(_7,_8){
var _9=editAreaLoader.getCurrentFile(_7).id;
var el=MVC.$E(_9);
if(!el&&_9){
return;
}
var _b=function(_c){
eval("var object = "+_c.responseText);
object.response=="Save"?editAreaLoader.setFileEditedMode(_7,_9,false):alert("save unsucessful");
el.innerHTML=new MVC.JFile(el.id).file_and_extension();
};
new MVC.Ajax("/ftp/save?path="+_9,{method:"post",postBody:"text="+encodeURIComponent(_8),onComplete:_b});
el.innerHTML="Saving ...";
};
File.file_name=function(_d){
return _d.id.match(/[^\/]*$/)[0].toLowerCase();
};
FileView={};
FileView.insert=function(_e,_f){
var _10=_e.match(/[^\/]*$/)[0],ret;
var div=document.createElement("div");
div.id=_e;
div.className="file";
div.setAttribute("type","file");
div.innerHTML=_10;
if(!_f){
_f=new MVC.JFile(_e).container();
}
var _13=_f.childNodes;
if(_13.length==0){
_f.appendChild(div);
new Draggable(div,{revert:true});
return div;
}
var _14=_13[_13.length-1];
if(_10.toLowerCase()>File.file_name(_14)||_14.getAttribute("type")=="directory"){
_f.appendChild(div);
new Draggable(div,{revert:true});
return div;
}
for(var i=0;i<_13.length;i++){
var _16=File.file_name(_13[i]);
var _17=_13[i].getAttribute("type");
if(_10.toLowerCase()<_16.toLowerCase()&&_17!="directory"){
_f.insertBefore(div,_13[i]);
new Draggable(div,{revert:true});
return div;
}
}
};
;
include.set_path('models');
DirectoryView=function(_1){
this.file=new MVC.JFile(_1);
this.path=_1;
};
DirectoryView.prototype={createElement:function(){
var _2=document.createElement("div");
_2.id=this.path;
_2.innerHTML=this.file.file_and_extension();
_2.className="directory";
_2.setAttribute("type","directory");
return _2;
},appendAsChildOf:function(_3){
this.element=_3.appendChild(this.toElement());
return this.element;
},toElement:function(){
if(this.element){
return this.element;
}
this.element=this.createElement();
return this.element;
},insertBefore:function(_4){
this.element=_4.parentNode.insertBefore(this.toElement(),_4);
return this.element;
}};
DirectoryView.insert=function(_5,_6,_7){
var _8=new DirectoryView(_5);
if(!_7){
_7=_8.file.container();
}
var _9=_7.childNodes;
for(var i=0;i<_9.length;i++){
var _b=_9[i];
var fd=new FileData(_b);
if(_8.file.file_and_extension()<fd.name||fd.type=="file"){
var _d=_8.insertBefore(_b);
var ps=new MVC.Controller.Params({element:_d});
MVC.Controller.dispatch("directories","load_directory",ps);
_7.insertBefore(Container(_6,_5),_d.next());
return _d;
}
}
var _d=_8.appendAsChildOf(_7);
var ps=new MVC.Controller.Params({element:_d});
MVC.Controller.publish("loaded_directory",ps);
_7.appendChild(Container(_6,_5));
return _d;
};
DirectoryView.rename=function(_f){
var _10=MVC.$E(_f.from_path);
var _11=_10.parentNode;
var _12=_10.next().remove();
_10.remove();
DirectoryView.insert(_f.to_path,_12);
DirectoryView.update(_f);
var _13=MVC.$E(_f.to_path).parentNode;
if(_11.childNodes.length==0){
_11.style.display="none";
}
};
DirectoryView.update=function(_14,_15){
var _16=(_14.directory!="/"?MVC.$E(_14.directory).next():MVC.$E("/").next());
_14.path_prepend=(_14.directory!="/"?_14.directory+"/":"/");
var _17=$A(_14.files).sort(File.sort);
var _18=DirectoryView.clean(_16,_17);
for(var i=0;i<_18.length;i++){
var _1a=_18[i];
if(_1a.name=="."||_1a.name==".."||_1a.name.indexOf("->")!=-1){
continue;
}
if(_1a.type=="file"){
FileView.insert(_14.path_prepend+_1a.name,_16);
}else{
var _1b=DirectoryView.insert(_14.path_prepend+_1a.name,null,_16);
}
}
if(!_15){
_16.show();
}
};
DirectoryView.clean=function(_1c,_1d){
var _1e=_1c.childNodes;
var _1f=[];
var _20=0;
if(_1e.length==0){
return _1d;
}
for(var i=0;i<_1e.length;i++){
var _22=_1e[i];
var fd=new FileData(_22);
var _24=_22.getAttribute("type");
if(!_24){
continue;
}
var _25=false;
while(_20<_1d.length){
var _26=_1d[_20];
if(_26.name=="."||_26.name==".."){
_20++;
continue;
}
if(_26.name==fd.name&&_24==_26.type){
_20++;
_25=true;
break;
}
if(_24=="file"&&_26.type=="directory"){
break;
}
if(_26.name>fd.name){
break;
}
_1f.unshift(_26);
_20++;
}
if(!_25){
_22.remove();
}
}
while(_20<_1d.length){
var _26=_1d[_20];
_1f.push(_26);
_20++;
}
return _1f;
};
;
include.set_path('controllers');
MainController=$.Controller.extend("main",{check:function(_1){
if(_1.response=="NoSession"){
alert("You have been logged out.  Please log in again to resume.");
location.href="/ftp/index?nosession";
return false;
}
return true;
},old_selected_id:function(){
return null;
},set_selected:function(_2){
if(MainController.removed_selected){
MainController.removed_selected();
}
var _3=_2.style;
_3.backgroundColor="rgb(49,103,197)";
_3.color="white";
_2.selected=true;
var id=_2.id;
MainController.removed_selected=function(){
_3.backgroundColor="";
_3.color="";
};
MainController.old_selected_id=function(){
return id;
};
},stack:[],autoload:function(){
if(MainController.stack.length==0){
var _5=MVC.$E("/").next().firstDescendant();
while(_5){
if(isFolder(_5)){
MainController.stack.push(_5.id);
}else{
if(isFile(_5)){
break;
}
}
_5=_5.next();
}
}
var _6=MainController.find_from();
if(!_6){
alert("everything found");
return;
}
new MVC.Ajax("/ftp/dir?path="+encodeURIComponent(_6.id),{method:"post",postBody:"",onComplete:MainController.update});
},find_from:function(){
var _7=MainController.stack.shift();
while(_7){
el=MVC.$E(_7);
if(needsOpening(el)){
return el;
}
_7=MainController.stack.shift();
}
return null;
},update:function(_8){
setTimeout(function(){
eval("var files = "+_8.responseText);
setTimeout(function(){
var _9=MVC.$E(files.directory).next();
var _a=$A(files.files).sort(File.sort);
new EJS({url:"/templates/files.ejs"}).update(_9,{files:_a,directory:files.directory+"/"});
_9.hide();
var fd=_9.firstDescendant();
},200);
},200);
}},{load:function(_c){
var _d;
(function(){
var _e;
MainController.set_upload_path=function(p){
_e=p;
};
_d=function(_10,_11){
var div=FileView.insert((_e!="/"?_e+"/":"")+_10);
div.style.visibility="hidden";
var to=Element.cumulativeOffset(div);
var i=MainController.fancy_upload.findFile(_10,_11);
var el=MainController.fancy_upload.fileList[i].element;
el.innerHTML=_10;
var _16=Element.cumulativeOffset(el);
new Effect.Move(el,{x:(to[0]-_16[0]),y:(to[1]-_16[1]),mode:"relative",duration:0.5,afterFinish:function(){
div.style.visibility="";
MainController.fancy_upload.remove(_10,_11);
}});
};
})();
MainController.fancy_upload=new FancyUpload(MVC.$E("photoupload-filedata-1"),{swf:"/swf/Swiff.Uploader.swf",queueList:"photoupload-queue",container:MVC.$E("h1"),types:{"All Files (*.*)":"*.*"},onComplete:_d,container:MVC.$E("Upload")});
},unload:function(_17){
if(frames["multipleupload"]){
var _18=frames["multipleupload"].document.getElementById("Swiff1");
if(_18){
_18.parentNode.removeChild(_18);
}
}
},resize:function(_19){
setTimeout(set_height,1);
},click:function(_1a){
if(MVC.$E("rename")){
var _1b=new MVC.JFile(MVC.$E("rename").parentNode.id).file_and_extension();
MVC.$E("rename").parentNode.innerHTML=_1b;
}
},keypress:function(_1c){
if(_1c.event.ctrlKey&&_1c.event.charCode==115){
alert("call save on edit area");
stopPropagation(_1c.event);
}
if(_1c.event.charCode==8&&Range.getWindowRange().isDocumentSelected()){
stopPropagation(_1c.event);
}
}});
needsOpening=function(el){
if(!isFolder(el)){
return false;
}
var _1e=el.next();
return _1e.style.display!="none"&&_1e.innerHTML=="";
};
isFolder=function(el){
return el.getAttribute("type")=="directory";
};
isFile=function(el){
return el.getAttribute("type")=="file";
};
cont=function(_21){
return function(){
if(isFolder(_21)){
MainController.stack.push(_21.id);
}
_21=_21.next();
if(!_21||isFile(_21)){
setTimeout(MainController.autoload,200);
}else{
setTimeout(cont(_21),200);
}
};
};
;
include.set_path('controllers');
FilesController=$.Controller.extend("files",{mouseover:function(_1){
var el=_1.element;
if(el.id!=MainController.old_selected_id()){
el.style.backgroundColor="#E8EEF7";
}
},mouseout:function(_3){
var el=_3.element;
if(el.id!=MainController.old_selected_id()){
el.style.backgroundColor="";
}
},dblclick:function(_5){
IDE.clear_selection();
var el=_5.element;
MainController.set_selected(el);
this.element=el;
this.title=el.innerHTML;
el.innerHTML="Opening ...";
new MVC.Ajax("/ftp/open?path="+encodeURIComponent(el.id),{method:"post",postBody:"",onComplete:this.continue_to("opened")});
},opened:function(_7){
this.element.innerHTML=this.title;
var id=this.element.id;
var f=new MVC.JFile(id);
var _a={id:id,text:_7.responseText,syntax:f.extension().toLowerCase(),title:f.file_and_extension()};
editAreaLoader.openFile("EDITAREA_TEXTAREA",_a);
},contextmenu:function(_b){
MainController.set_selected(_b.element);
var _c=JITS.rightClickMenu.open(this.render(),_b.event);
_b.event.kill();
},click:function(_d){
MainController.set_selected(_d.element);
}});
;
include.set_path('controllers');
DirectoriesController=$.Controller.extend("directories",{load:function(_1){
var ps=new MVC.Controller.Params({event:_1.event,element:MVC.$E("/"),leave_state:true});
this.dblclick(ps);
var _3=(window.innerHeight?window.innerHeight:MVC.$E(document.documentElement).getHeight());
MVC.$E("FILES").style.height=(_3-32)+"px";
MVC.$E("files_container").style.height=(_3-0)+"px";
var ps=new MVC.Controller.Params({element:MVC.$E("/")});
this.load_directory(ps);
},mouseover:function(_4){
var el=_4.element;
if(el.id!=MainController.old_selected_id()){
el.style.backgroundColor="#E8EEF7";
}
},mouseout:function(_6){
var el=_6.element;
if(el.id!=MainController.old_selected_id()){
el.style.backgroundColor="";
}
},click:function(_8){
MainController.set_selected(_8.element);
},contextmenu:function(_9){
MainController.set_selected(_9.element);
var _a=JITS.rightClickMenu.open(this.render(),_9.event);
_9.event.kill();
return false;
},dblclick:function(_b){
IDE.clear_selection();
var el=_b.element;
var _d=el.next();
var _e=_d.childElements().size();
if(_e!=0){
if(_b.leave_state){
return _d.style.display==""||_d.style.display=="block"?null:Effect.BlindDown(_d);
}else{
return _d.style.display==""||_d.style.display=="block"?Effect.BlindUp(_d,{duration:_e/30}):Effect.BlindDown(_d,{duration:_e/30});
}
}
_d.style.display="";
_d.innerHTML="Loading ...";
this.container=_d;
new MVC.Ajax("/ftp/dir?path="+encodeURIComponent(el.id),{method:"post",postBody:"",onComplete:this.continue_to("files_loaded")});
},files_loaded:function(_f){
eval("var response_object = "+_f.responseText);
if(!MainController.check(response_object)){
return;
}
this.container.innerHTML="";
if(response_object.files.length<100){
this.container.style.display="none";
}
if(response_object.files.length<=2){
return;
}
DirectoryView.update(response_object,true);
if(response_object.files.length<100){
var _10=response_object.files.length;
Effect.BlindDown(this.container,{duration:response_object.files.length/30});
}
},"loaded_directory subscribe":function(_11){
this.load_directory(_11);
},load_directory:function(_12){
var _13=_12.element;
this.dropped_on=_13;
Droppables.add(_13,{hoverclass:"hover",onDrop:this.continue_to("dropped")});
new Draggable(_13,{revert:true});
},dropped:function(_14){
var _15=_14.id;
var _16=_14.getAttribute("type");
if(_16=="directory"&&MVC.$E(this.dropped_on).descendantOf(_14.next())){
alert("You can't put a folder inside itself!");
return;
}
var _17=new MVC.JFile(_15);
var _18=(this.dropped_on.id=="/"?"":this.dropped_on.id)+"/"+_17.file_and_extension();
if(_16=="file"){
new MVC.Ajax("/ftp/rename_file?from_path="+encodeURIComponent(_15)+"&to_path="+encodeURIComponent(_18),{onSuccess:this.continue_to("file_renamed"),asynchronous:true,evalScripts:false});
}else{
new MVC.Ajax("/ftp/rename_folder?from_path="+encodeURIComponent(_15)+"&to_path="+encodeURIComponent(_18),{onSuccess:this.continue_to("folder_renamed"),asynchronous:true,evalScripts:false});
}
this.dragged=_14;
this.dragged.style.color="Gray";
this.dragged.innerHTML="Moving ...";
},file_renamed:function(_19){
eval("var object = "+_19.responseText);
if(object.response!="Renamed File"){
alert(object.response);
return;
}
var _1a=MVC.$E(object.from_path);
var _1b=_1a.parentNode;
MVC.$E(_1a).remove();
if(_1b.childNodes.length==0){
_1b.style.display="none";
}
var f=new MVC.JFile(object.to_path);
editAreaLoader.getRenameFile("EDITAREA_TEXTAREA",object.from_path,object.to_path,f.file_and_extension());
DirectoryView.update(object);
var _1d=MVC.$E(object.to_path).parentNode;
new Effect.Highlight(object.to_path,{startcolor:"#C3D9FF",duration:0.7});
},folder_renamed:function(_1e){
eval("var object = "+_1e.responseText);
if(object.response!="Renamed Folder"){
alert(object.response);
return;
}
DirectoryView.rename(object);
}});
;
include.set_path('controllers');
MenuController=$.Controller.extend("menu",{".new_file click":function(_1){
path=_1.element.getAttribute("folder");
this.element=MVC.$E(path);
if(path=="/"){
path="";
}
new MVC.Ajax("/ftp/new_file?path="+path,{onSuccess:this.continue_to("update_directory"),asynchronous:true,evalScripts:false});
this.title=this.element.innerHTML;
this.element.style.color="Gray";
this.element.innerHTML="creating new file ... ";
},update_directory:function(_2){
eval("var object = "+_2.responseText);
this.element.style.color="";
this.element.innerHTML=this.title;
if(object.response!="New File"&&object.response!="Dir"&&object.response!="New Folder"&&object.response!="Upload"&&object.response!="Renamed File"&&object.response!="Renamed Folder"){
alert(object.response);
return;
}
DirectoryView.update(object);
new Effect.Highlight([object.directory,object.new_file].join("/"),{startcolor:"#C3D9FF",duration:0.7});
},".new_folder click":function(_3){
path=_3.element.getAttribute("folder");
this.element=MVC.$E(path);
if(path=="/"){
path="";
}
new MVC.Ajax("/ftp/new_folder?path="+path,{onSuccess:this.continue_to("update_directory"),asynchronous:true,evalScripts:false});
this.title=this.element.innerHTML;
this.element.style.color="Gray";
this.element.innerHTML="creating new folder ... ";
},".rename click":function(_4){
this.element=MVC.$E(_4.element.getAttribute("folder"));
this.name=new MVC.JFile(this.element.id).file_and_extension();
this.render({to:this.element});
JITS.rightClickMenu.clear();
_4.event.kill();
MVC.$E("RENAME_FORM_NEW_NAME").focus();
},".delete click":function(_5){
var _6=MVC.$E(_5.element.getAttribute("folder"));
var _7=_6.className.startsWith("file");
if(include.get_env()!="test"&&!(_7?confirm("Delete File?"):confirm("Delete Folder?"))){
return false;
}
var _8=_6.id;
this.path=_8;
_6.style.color="Gray";
_6.innerHTML="deleting ...";
if(_7){
new MVC.Ajax("/ftp/delete_file?path="+_8,{onSuccess:this.continue_to("file_deleted"),asynchronous:true,evalScripts:false});
}else{
new MVC.Ajax("/ftp/delete_folder?path="+_8,{onSuccess:this.continue_to("file_deleted"),asynchronous:true,evalScripts:false});
}
},file_deleted:function(_9){
eval("var object = "+_9.responseText);
if(object.response!="Delete File"){
alert(object.response);
MVC.$E(this.path).innerHTML=new MVC.JFile(this.path).file_and_extension();
return;
}
editAreaLoader.closeFile("EDITAREA_TEXTAREA",object.path);
var el=MVC.$E(object.path);
if(el.className.startsWith("folder")){
el.next().remove();
}
Effect.DropOut(el,{afterFinish:function(_b){
var _c=_b.effects[0].element;
var _d=_c.parentNode;
_b.effects[0].element.remove();
if(_d.childNodes.length==0){
_d.style.display="none";
}
}});
},".upload click":function(_e){
var _f=_e.element.getAttribute("folder");
MVC.$E("Upload").style.display="block";
var _10=new MVC.JFile(_f).file_and_extension();
MVC.$E("upload_form_folder_name").innerHTML=new MVC.JFile(_f).file_and_extension()||"/";
MainController.fancy_upload.options.url="/upload?_ftp_session_id="+readCookie("_ftp_session_id")+"&path="+_f;
MainController.set_upload_path(_f);
set_height();
var ps=new MVC.Controller.Params({event:_e.event,element:MVC.$E(_f),leave_state:true});
MVC.Controller.dispatch("directories","dblclick",ps);
}});
;
include.set_path('controllers');
RenameController=$.Controller.extend("rename",{submit:function(_1){
_1.event.kill();
var _2=_1.element;
var _3=$F("RENAME_FORM_PATH");
var _4=$F("RENAME_FORM_NEW_NAME");
var _5=_3.split("/");
_5[_5.length-1]=_4;
var _6=_5.join("/");
_2.innerHTML="Renaming ...";
_2.style.color="Gray";
if(MVC.$E(_3).className.startsWith("file")){
new MVC.Ajax("/ftp/rename_file?from_path="+encodeURIComponent(_3)+"&to_path="+encodeURIComponent(_6),{onSuccess:this.continue_to("renamed_file"),asynchronous:true,evalScripts:false});
}else{
new MVC.Ajax("/ftp/rename_folder?from_path="+encodeURIComponent(_3)+"&to_path="+encodeURIComponent(_6),{onSuccess:this.continue_to("renamed_folder"),asynchronous:true,evalScripts:false});
}
return false;
},renamed_folder:function(_7){
eval("var object = "+_7.responseText);
if(object.response!="Renamed Folder"){
alert(object.response);
return;
}
DirectoryView.rename(object);
},renamed_file:function(_8){
eval("var object = "+_8.responseText);
if(object.response!="Renamed File"){
alert(object.response);
return;
}
MVC.$E(object.from_path).remove();
f=new MVC.JFile(object.to_path);
editAreaLoader.getRenameFile("EDITAREA_TEXTAREA",object.from_path,object.to_path,f.file_and_extension());
DirectoryView.update(object);
},load:function(_9){
},"input blur":function(_a){
},"input click":function(_b){
_b.event.kill();
}});
;
include.end_of_production();